完成一个猜数字游戏,要求有提示大小。
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i,j;
srand (time(NULL));
i = rand()%10000;
while ( 1 )
{
printf("猜一个数字:"); 多了一个\n 让程序陷入了死循环
scanf("%d",&j);
if(j>i)
{
printf("猜大了\n");
}
else if(j<i)
{
printf("猜小了\n");
}
else
{
printf("猜对了\n");
break;
}
}
return 0;
}
编写程序,打印菱形星号组合
#include <stdio.h>
int main()
{
printf("\n\
*\n\
* *\n\
* *\n\
* *\n\
* *\n\
* *\n\
*\n");
return 0;
}
编写程序,打印出9×9乘法表
#include <stdio.h>
int main()
{
int i,j,m;
for (i=1;i<10;i++)
{
for (j=1;j<=i;j++)
{
m=i*j;
printf("%d*%d=%d\t",i,j,m);
}
printf("\n");
}
return 0;
}