19-11-2007, 00:42
|
|
|
חבר מתאריך: 17.05.05
הודעות: 7,321
|
|
עובד פרפקט!
קוד:
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
using namespace System;
int main(array<System::String ^> ^args)
{
char num, storeDigit[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
short current, iter;
printf("Please print a number between 0-9:");
while((num = getchar()) && num>'0' && num<='9') // Validation
for(current=iter=(num-'0'); iter>0; --iter ) // Rows to print
{
for(short times=(num-'0')-iter; times>0; --times)
printf(" ");
while( current > 1)
printf("%c", storeDigit[current--]);
while( current <= iter)
printf("%c", storeDigit[current++]);
puts("\n");
current -= 2;
}
getch();
return 0;
}
יש לך עוד משימות?
|