基本上,我需要编写一个程序,程序要求用户输入特定的数字来获得特定的形状。比如1代表椭圆,2代表矩形等等,程序需要不断要求用户输入数字,直到用户输入数字9结束程序。这是 Turbo C 中的最终工作代码
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main ()
{
clrscr();
int x=0;
while(x != 9)
{
printf ("Enter 1,2,3 and 4 for differeten shape and 9 to exit: ");
scanf ("%d",&x);
if (x == 1)
{
printf ( "*********\n"
"* *\n"
"* *\n"
"* *\n"
"* *\n"
"* *\n"
"* *\n"
"* *\n"
"*********\n");
}
else if (x == 2)
{
printf (" *** \n"
" * * \n"
"* *\n"
"* *\n"
"* *\n"
"* *\n"
"* *\n"
" * * \n"
" *** \n");
}
else if (x ==3)
{ printf( " * \n"
" *** \n"
" ***** \n"
" * \n"
" * \n"
" * \n"
" * \n"
" * \n"
" * \n");
}
else if (x==4)
{printf (" * \n"
" * * \n"
" * * \n"
" * * \n"
"* * \n"
" * * \n"
" * * \n"
" * * \n"
" * \n");}
}
printf("The end\n");
system("pause");
return 0;
}