#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次参照物来比较, 因 ...
随机推荐
- 洛谷 P4297 [NOI2006]网络收费
P4297 [NOI2006]网络收费 题目背景 noi2006 day1t1 题目描述 网络已经成为当今世界不可或缺的一部分.每天都有数以亿计的人使用网络进行学习.科研.娱乐等活动.然而,不可忽视的 ...
- Qt 学习之路 2(1):序
https://www.devbean.net/category/qt-study-road-2/page/10 原来开过QT学习之路1, 很棒, 再翻阅时已经没有了. 所以这次把看过的记录下来 Ho ...
- react 的理念
命名式的编程方式: 命名式的编程方式,我们会有百分之六七十都在进行dom的操作. 1.声名式的开发: react是面向数据开发的,react是根据这个数据自动构建这个网站,可以把数据理解成图纸,rea ...
- POJ2676 (数独问题 + DLX + 状态优化顺序)
(1)最简单的最是去暴力DFS搜索答案 , 很容易想到 , 每行每列的方式去搜索 , 不过效率是真的不行;但这个还是给出代码 ,毕竟打了也不容易呀! #include<cstdio> #i ...
- Codeforces Round #335 (Div. 2) A
A. Magic Spheres time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- jupyter notebook初步使用
Jupyter Notebook(此前被称为 IPython notebook)是一个交互式笔记本,支持运行 40 多种编程语言.在本文中,我们将介绍 Jupyter notebook 的主要特性,以 ...
- 懒汉式单例要加volatile吗
private static volatile Something instance = null; public static Something getInstance() { if (insta ...
- 复制虚拟机出现”适配器 的mac地址在保留地址范围内‘’
首先我的虚拟机是复制出来的,选择我已经移到,但是结果会出现了以下情况,导致了我无法ping 通,先看下提示: 使用:ipconfig –all 命令查寻,果然再现有打开的虚拟机中,存在两个mac地址相 ...
- mpdf Could not find image file (http://local.com/xxxxx)
记录一下昨天和今天遇到的,yii2使用mpdf的时候,图片是使用php方法生成的二维码,所以图片地址为http://local.com/xxxxx,url中携带不同的参数. 但是开启了 $mpdf-& ...
- 6-----BBS论坛
BBS论坛(六) 6.1.优化json数据的返回 (1)新建utils/restful.py # utils/restful.py from flask import jsonify class Ht ...