#include stdio.h(7)
#include <stdio.h>
int main()
{
//***********一、循环语句***************
//什么叫做循环:
//重复的做某件事情,重复的执行一段代码
//什么时候用循环: //1、while语句(会先根据判断条件是否满足,在决定是否循环)
/*
whlie(表达式1)
{
如果表达式1成立。就会执行{}里面的语句
语句1; 当执行完语句1的时候,
循环会对循环条件进行重新判断,
如果循环条件满足则继续循环,
如果不满足则退出循环,
执行循环下面的代码
}
*/ //利用while循环计算1-100里面的7的倍数
int num = ;
while(num<=)//循环条件是num≤100
{
if(num% == )//
{
printf("num=%d\n",num);
}
num++;
} //2、do-while语句(无论循环条件是否满足,程序都会先执行1遍循环的代码)
/*
do
{
循环体;
}while(判断表达式); */ int num1 = ;
do
{
if(num1% == )
{
printf("num1=%d",num1);
}
num1++;
}while(num1<=); //3、for循环语句
/*
表达式1:设置循环的初始值,即从即开始循环
表达式2:循环判断条件
表达式3:循环变量的改变
注意:
1、每个表达式用分号隔开
2、正真的循环顺序是
表1->表2-(满足)->语句4->表3->表2->语句4
|(不满足) |
跳出循环 跳出 1->2->4->3->2->4->3 2-4-3
for(表1;表2;表3)
{
循环语句4
}
*/ for(int i=;i<;i++)
{
//要执行循环代码
if(i% == )
{
printf("i=%d\n",i);
}
} for(int j=;j>;j--)
{
if(j% == )
{
printf("j=%d\n",j);
}
} /*
双层for循环和多层for循环
1、从外层开始
2、执行到内层的时候,
会把内层循环全部循环一次,在执行一次外部循环
3、多层循环机制和钟表的机制是一样的
4、f1(1次)->f2(60次)->f3(3600次) for(表1;表2;表3) //时针
{
循环语句4
for(表1;表2;表3) //分针(60次)
{
for(。。。) //秒针 (60次)
{ }
}
}
*/ //一共会循环5*3 =15
//当m=0的时候,小循环会把0,1,2执行,在m变成1
//当m=1的时候,小循环会把0,1,2
for(int m=;m<;m++)//0,1,2,3,4
{
printf("\n这是大循环,并且当前m=%d",m);
for(int n=;n<;n++)//0,1,2
{
printf("这是小循环,当前n=%d",n);
}
} for(int a = ;a<;a++)
{
//如果有换行,外层循环控制行数
printf("\n\n");
for(int b=;b<;b++)//列数
{
printf("%d*%d=%d ",a,b,a*b);
//a=0 ,b=0,1,2,3
//a=1 ,b=0,1,2,3
}
} /*
*****
*****
*****
*****
*/ for(int c=;c<;c++)
{
printf("\n");
for(int d=;d<;d++)
{
printf("*");
}
} /*
第一个作业
***** ***** * *
**** **** ** **
*** *** *** ***
** ** **** ****
* * ***** ***** 第二个作业
1*1 =1 2*1=2
1*2 =2
1*3 =3
。
。
。
。
。
1*9=9 */ return ;
}
#include stdio.h(7)的更多相关文章
- 第二次作业#include <stdio.h> int main() { int a,b,c,d,e; printf("请输入一个不多于五位的整数:\n"); scanf("%d",&a); if(a>=100000||a<=0) { printf("输入格式错误! \n"); } else { if(
1 判断成绩等级 给定一百分制成绩,要求输出成绩的等级.90以上为A,80-89为B,70-79为C,60-69为D,60分以下为E,输入大于100或小于0时输出"输入数据错误". ...
- c语言输入与输出库函数#include<stdio.h>
last modified: 2010-05-28 输入与输出<stdio.h> 头文件<stdio.h>定义了用于输入和输出的函数.类型和宏.最重要的类型是用于声明文件指针的 ...
- #include <stdio.h>
1 fflush 2 fgetc 3 fgets 4 fprintf 5 fputc 6 fputs 7 fscanf 8 fseek 9 ftell 10 perror 11 remove 12 r ...
- error: /usr/include/stdio.h: Permission denied 的一种情况分析
error: /usr/include/stdio.h: Permission denied 的一种情况分析 代码: #include <stdio.h> int main(){ prin ...
- #include<stdio.h> #include "stdio.h"
https://baike.baidu.com/item/#include <stdio.h> #include <stdio.h> 编辑 #include<stdio. ...
- #include stdio.h(B)
#include <stdio.h> int main() { //***********一.循环语句*************** //什么叫做循环: //重复的做某件事情,重复的执行一 ...
- #include stdio.h(A)
/* 第一个*******知识点工程相关信息******** 1.创建工程 文件->新建->工程->win32 console applecation ->文件名不能为汉字 2 ...
- #include stdio.h(6)
#include <stdio.h> int main() { //**************3.字符数组************** ] = {'i','P','\0','o','n' ...
- #include stdio.h(5)
#include <stdio.h> int main() { //1.数组的排序-冒泡排序 /* 1.规则:相邻的两个数据进行比较 2.如果有N个数据,需要选择N-1次参照物来比较, 因 ...
随机推荐
- 洛谷 P1801 黑匣子_NOI导刊2010提高(06)
题目描述 Black Box是一种原始的数据库.它可以储存一个整数数组,还有一个特别的变量i.最开始的时候Black Box是空的.而i等于0.这个Black Box要处理一串命令. 命令只有两种: ...
- 利用DSB2017冠军开源代码为LUNA16生成mask
代码地址:https://github.com/lfz/DSB2017 先展示下生成的mask与真实mask subset9 subset8 subset7 subset6 subset5 subse ...
- vue.js 基础
vuejs 遍历 数组, vue js 文章 http://www.cnblogs.com/libin-1/p/6851775.html https://zhuanlan.zhihu.com/p/ ...
- 80C51单片机介绍
80C51单片机属于MCS-51系列单片机,由Intel公司开发,其结构是8048的延伸,改进了8048的缺点. 增加了如乘(MUL).除(DIV).减(SUBB).比较(CMP).16位数据指针.布 ...
- Luogu P1120 小木棍 [数据加强版] 来来来我们一起来剪枝,剪枝,剪枝、、、
好啊...太棒了... dfs(拼到第几根木棍,这根木棍剩余长度,上一根木棍的位置) len是木棍的长度,cnt是木棍的个数 震撼人心的剪枝: 1.枚举长度从最大的木棍开始,直到sum/2,因为之后只 ...
- Codeforces 277E
按边建模,二叉树一条入边两条出边 判断就要用到mcmf的好处了 #include<bits/stdc++.h> using namespace std; const int maxn = ...
- java重载equals和hashCode
class Employee { private int salary; private java.util.Date hireDay; private String name; public int ...
- 求用1g、2g、3g的砝码(每种砝码有无穷多个)称出10g的方案有几种
#include <iostream> using namespace std; // ; // sup是保存多项式的数组,sup[n]中的值代表指数为i的系数 ,下标i是x的指数 // ...
- MVC中Cookies的简单读写操作
写入 public static void WriteCookie(string cn, string cv, DateTime Time) { HttpCookie cookie = new Htt ...
- 1.3 IDAE安装GO插件
点击Configure,选择插件Plugins 安装后重启一下IDEA D:\app\Go是Go的安装路径,没有的话,可以下载安装一下Go 选择go项目的代码位置 创建三个文件夹,在src下进行编码 ...