#import <Foundation/Foundation.h>
int main(int argc, const charchar * argv[]) {
//循环语句while
//死循环
/*
while (YES) {
printf("根本停不下来...");
}
*/
//打印十次 天黑路滑,社会复杂
//循环十次
int count = 0;
while (count<10) {
printf("天黑路滑,社会复杂\n");
//每次循环不要忘了+1
count++;
}
//输出5-20之间的数字
int count1 = 5;
while (count1<=20) {
printf("%d\n",count1);
count1++;
}
//输出1-100之间个位数字是7的数
//17 27 37 47 57
//17%10 = 7 27%10 = 7
int count2 = 1;
while (count2<=100) {
if (count2%10 == 7) {
printf("%d\n",count2);
}
count2++;
}
//输出n个1-100之间的数字 n从控制台输入
//格式化输入函数
int number = 0;
printf("请输入number的值:\n");
scanf("%d",&number);
printf("当前number的值为%d\n",number);
int count3 = 0;//控制循环次数
while (count3<number) {
int result = arc4random()%100+1;
printf("%d\n",result);
count3++;
}
//do-while
//先执行一次do里面的代码 再去判断条件是否满足
int count4 = 0;
do {
printf("王尼玛\n");
count4++;
} while (count4<0);
return 0;
} |