看翁凯老师的c语言,做个笔记
因为用腾讯的cloudstudio没法用scanf函数,所以一开始直接定义了一个数,今天查了一下用rand和time生产随机数,更新一下
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
//逆序输出
{
int number;
srand((unsigned)time(0));
number=rand() %1000+66;
printf("number=%d\n",number);//生产数
//scanf("%d",&number);
int qvchu;
int result=0;
/*while (number>0)
{
qvchu=number%10;
result=result*10+qvchu;
number=number/10;
printf("number=%d qvchu=%d shuchu=%d\n",number,qvchu,result);
}*///可以调试看循环过程
for ( ; number > 0; number=number/10)
{
qvchu=number%10;
result=result*10+qvchu;
}
printf("%d",result);
return 0;
}