热门

最新

红包

立Flag

投票

同城

我的

发布
m0_50813132
gm110308
5 年前
truem0_50813132

#include <stdio.h>

/*
程序中的逻辑控制
循环语句:
for语句
while语句
do...while语句

by 赵志远

*/
int main()
{
int num = 0;
printf("请出入打印 hello world 的次数:\n");
scanf("%d",&num);

//for 循环语句
for(int i = 0;i<num; i++ )
{
printf("Hello World!\n");
}
printf("使用for循环语句一共打印了%d次 hello world\n",num);

printf("请出入打印 hello china 的次数:\n");
scanf("%d",&num);

int tmp = num;
//while循环语句
while(num> 0)
{
printf("Hello China!\n");
num--;
}
printf("使用while循环语句一共打印了%d次 hello China\n",tmp);


printf("请出入打印 hello bei jing 的次数:\n");
scanf("%d",&num);
tmp = num;

//do...while循环语句
do
{
printf("Hello Bei Jing!\n");
num--;
}
while( num> 0);

printf("使用do...while循环语句一共打印了%d次 hello bei jing\n",tmp);

return 0;
}


















CSDN App 扫码分享
分享
评论
1
打赏
  • 复制链接
  • 举报
下一条动态
立即登录