C语言第4天循环,流程控制。
C语言第四天
:first-child { margin-top: 0; } blockquote > :last-child { margin-bottom: 0; } img { border: 0; max-width: 100%; height: auto !important; margin: 2px 0; } table { border-collapse: collapse; border: 1px solid #bbbbbb; } td, th { padding: 4px 8px; border-collapse: collapse; border: 1px solid #bbbbbb; } @media only screen and (-webkit-max-device-width: 1024px), only screen and (-o-max-device-width: 1024px), only screen and (max-device-width: 1024px), only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (-o-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) { html, body { font-size: 17px; } body { line-height: 1.7; padding: 0.75rem 0.9375rem; color: #353c47; } h1 { font-size: 2.125rem; } h2 { font-size: 1.875rem; } h3 { font-size: 1.625rem; } h4 { font-size: 1.375rem; } h5 { font-size: 1.125rem; } h6 { color: inherit; } ul, ol { padding-left: 2.5rem; } blockquote { padding: 0 0.9375rem; } }
-->
div{font-size:15px;}.wiz-table-tools .wiz-table-menu-item.active .wiz-table-menu-sub {display: block}.wiz-table-tools .wiz-table-menu-sub:before, .wiz-table-tools .wiz-table-menu-sub:after {position: absolute;content: " ";border-style: solid;border-color: transparent;border-bottom-color: #cccccc;left: 22px;margin-left: -14px;top: -8px;border-width: 0 8px 8px 8px;z-index:10;}.wiz-table-tools .wiz-table-menu-sub:after {border-bottom-color: #ffffff;top: -7px;}.wiz-table-tools .wiz-table-menu-sub-item {padding: 4px 12px;font-size: 14px;}.wiz-table-tools .wiz-table-menu-sub-item.split {border-top: 1px solid #E0E0E0;}.wiz-table-tools .wiz-table-menu-sub-item:hover {background-color: #ececec;}.wiz-table-tools .wiz-table-menu-sub-item.disabled {color: #bbbbbb;cursor: default;}.wiz-table-tools .wiz-table-menu-sub-item.disabled:hover {background-color: transparent;}.wiz-table-tools .wiz-table-menu-item.wiz-table-cell-bg:hover .wiz-table-color-pad {display: block;}.wiz-table-tools .wiz-table-color-pad {display: none;padding: 10px;box-sizing: border-box;width: 85px;height: 88px;background-color: #fff;cursor: default;}.wiz-table-tools .wiz-table-color-pad > div{font-size:15px;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item {display: inline-block;width: 15px;height: 15px;margin-right: 9px;position: relative;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item i.pad-demo {position: absolute;top:3px;left:0;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item .icon-oblique_line{color: #cc0000;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item:last-child {margin-right: 0;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item.active i.editor-icon.icon-box {color: #448aff;}.wiz-table-tools .wiz-table-cell-align {display: none;padding: 10px;box-sizing: border-box;width: 85px;height: 65px;background-color: #fff;cursor: default;}.wiz-table-tools .wiz-table-cell-align .wiz-table-cell-align-item {display: inline-block;width: 15px;height: 15px;margin-right: 9px;position: relative;}.wiz-table-tools .wiz-table-cell-align .wiz-table-cell-align-item:last-child {margin-right:0}.wiz-table-tools .wiz-table-cell-align .wiz-table-cell-align-item i.valign{position: absolute;top:3px;left:0;color: #d2d2d2;}.wiz-table-tools .wiz-table-cell-align-item.active i.editor-icon.valign {color: #a1c4ff;}.wiz-table-tools .wiz-table-cell-align-item.active i.editor-icon.icon-box,.wiz-table-tools .wiz-table-cell-align-item.active i.editor-icon.align {color: #448aff;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item:last-child,.wiz-table-tools .wiz-table-cell-align .wiz-table-cell-align-item:last-child {margin-right: 0;}th.wiz-selected-cell, td.wiz-selected-cell {background: rgba(0,102,255,.05);}th:before,td:before,#wiz-table-col-line:before,#wiz-table-range-border_start_right:before,#wiz-table-range-border_range_right:before{content: " ";position: absolute;top: 0;bottom: 0;right: -5px;width: 9px;cursor: col-resize;background: transparent;z-index:100;}th:after,td:after,#wiz-table-row-line:before,#wiz-table-range-border_start_bottom:before,#wiz-table-range-border_range_bottom:before{content: " ";position: absolute;left: 0;right: 0;bottom: -5px;height: 9px;cursor: row-resize;background: transparent;z-index:100;}.wiz-table-container {}.wiz-table-body {position:relative;padding:0 0 10px;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;}.wiz-table-body table {margin:0;outline:none;}td,th {height:28px;word-break:break-all;box-sizing:border-box;outline:none;}
-->
大小写转换代码<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">
# include <stdio.h>
int main(int argc,constchar*argv[])
{
#if 0
int a =10;
if(a>0)
printf("a>0");
elseif(a==0)
printf("a=0");
else
printf("a<0");
putchar(10);
return0;
#endif
puts("please input word");
int a =0;
a= getchar();
if('A'<=a&&a<='Z')
{
putchar(a+32);
}
elseif( a>='a'&&a<='z')
{
putchar (a-32);
}
else
puts("error");
}
#include<stdio.h>
int main(int argc,constchar*argv[])
{
int i =0, count_ji =0, count_ou =0, num_ji =0, num_ou =0;
while(1)
{
if(scanf("%d",&i)!=1)
{
puts("error");
return-1;
}
if(i ==0)
{
puts("end");
break;
}
if(i %2)
{
count_ji++;
num_ji += i;
}
else
{
count_ou++;
num_ou += i;
}
}
if(count_ji !=0)
{
num_ji /= count_ji;
}
if(count_ou !=0)
{
num_ou /= count_ou;
}
printf("count_ji = %d, count_ou = %d\n",count_ji, count_ou);
printf("平均值_ji = %d, 平均值_ou = %d\n",num_ji, num_ou);
return0;
}
int a =3;
int i=0,j=0;
float sum_ji=0;
float sum_ou=0;
while(1)
{
if( scanf("%d",&a)!=1)
{
return-1;
}
else
if(a==0)
{
puts("end");
break;
}
if(a%2==0)
{
i++;
sum_ou+=a;
}
else
{
j++;
sum_ji+=a;
}
}
printf("%d %d\n",i,j);
if(i!=0)
{
printf("%f\n",sum_ou);
}
if(j!=0)
{
printf("%f\n",sum_ji);
}
#endif
int a;
int xiaoshi=0,fen=0;
while(1)
{
if(scanf("%d",&a)!=1)
{
printf("try again!");
getchar();
continue;
}
else
{
xiaoshi=a/60;
fen= a%60;
printf("%02d:%02d\n",xiaoshi,fen);
}
}
return0;
}

# include <stdio.h>
int main(int argc,constchar*argv[])
{
/* int i=0;
int sum =0;
for( i=0;i<=10;i++)
{
sum+=i;
}
printf("%d\n",sum);
*/
int a,b,i,j;
for(i=1;i<=9;i++)
{
for(j=1;j<=i;j++)
{
printf("%-2d*%-2d=%-2d ",j,i,i*j);
}
putchar(10);
}
return0;
}
int i ;
int bai,shi,ge;
for(i=100;i<=999;i++)
{
ge = i%10;
shi=i/10%10;
bai=i/100;
// printf("%d\n%d\n%d\n",ge,shi,bai);
if(i==ge*ge*ge+shi*shi*shi+bai*bai*bai)
printf("%d\n",i);
}

int i,j,h;
for(i=1;i<7;i++)
{
for(j=i;j>=1;j--)
{
printf("_");
}
for(h=0;h<i;h++)
{
printf("%c",'F'-h);
}
putchar(10);
}
return0;
}
int i ,j;
for(i=2;i<100;i++)
{
for(j=2;j<=i;j++)
{
if(( i%j==0)&&(i!=j))
break;
if(i==j)
printf("%d\n",i);
}
}
# include <stdio.h>
int main(int argc,constchar*argv[])
{
int nian,yue,ri;
int flag =1;
int sum=0;
while(1)
{
puts("please input:");
if(scanf("%d %d %d",&nian,&yue,&ri)!=3)
{
puts("input error,try again:");
getchar();
getchar();
getchar();
continue;
}
if((nian<0||nian>=9999)||0>yue||yue>12)
{
puts("输入错误!请重新输入");
continue;
}
//判断输入到数字是否合理
if(yue==1||yue==3||yue==5||yue==7||yue==8||yue==10||yue==12)
{
if(0>ri||ri>31)
{
puts("日输入错误!请重新输入");
continue;
}
}
if(yue==4||yue==6||yue==9||yue==11)
{
if(ri>30)
{
puts("日输入错误!请重新输入");
continue;
}
}
{
if((nian%4==0)&&(nian%100!=0)||nian%400==0)
{
flag=1;
if(yue==2)
if(ri<0||ri>29)
{
puts("日输入错误!请重新输入");
continue;
}
}
else
{
if(yue==2)
if(ri<0||ri>28)
{
puts("日输入错误!请重新输入");
continue;
}
flag=0;
}
}
switch(yue-1)
{
case11:sum+=30;
case10:sum+=31;
case9:sum+=30;
case8:sum+=31;
case7:sum+=31;
case6:sum+=30;
case5:sum+=31;
case4:sum+=30;
case3:sum+=31;
case2:{if(flag)sum+=29;else sum+=28;}
case1:sum+=31;
}
printf("%d\n",sum+ri);
sum=0;
}
return0;
}
C语言第4天循环,流程控制。的更多相关文章
- GO语言的进阶之路-流程控制
GO语言的进阶之路-流程控制 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 流程控制在编程语言中是最伟大的发明了,因为有了它,你可以通过很简单的流程描述来表达很复杂的逻辑.流程控制 ...
- 循环流程控制&方法(3)
1.循环流程控制 当某一段代码需要重复执行多次的时候,就需要用到循环: 循环三要素: 循环的起点:循环的终点(结束条件):步长: 当循环条件不再成立,结束循环: for循环 for(循环起点:循环条件 ...
- day05流程控制while循环 流程控制for循环
1.什么是循环:循环就是重复做某事 2.为何要有循环:为了计算机能够具备人重复做某事的能力 3,.如何用循环: 1.结束while循环的两种方法:1.修改条件:等到下一次循环开始时判断,条件为假才会结 ...
- 【原创】go语言学习(四)流程控制
目录: 1.if else语句块 2.for语句 3.switch语句 if else语句块 1.基本语法 if condition { //do something } if statement; ...
- Go语言基础之流程控制
Go语言基础之流程控制 流程控制是每种编程语言控制逻辑走向和执行次序的重要部分,流程控制可以说是一门语言的“经脉”. Go语言中最常用额流程控制有if和for,而switch和goto主要是为了简化代 ...
- Go语言( 流程控制)
流程控制是每种编程语言控制逻辑走向和执行次序的重要部分,流程控制可以说是一门语言的“经脉”. Go语言中最常用的流程控制有if和for,而switch和goto主要是为了简化代码.降低重复代码而生的结 ...
- Go语言 - 流程控制 if else | for | switch case
流程控制 流程控制是每种编程语言控制逻辑走向和执行次序的重要部分,流程控制可以说是一门语言的“经脉”. Go语言中最常用的流程控制: if | for | switch | goto// switch ...
- 1.4 Go语言基础之流程控制
流程控制是每种编程语言控制逻辑走向和执行次序的重要部分,流程控制可以说是一门语言的"经脉". Go语言中最常用的流程控制有if和for,而switch和goto主要是为了简化代码. ...
- GO学习-(7) Go语言基础之流程控制
流程控制是每种编程语言控制逻辑走向和执行次序的重要部分,流程控制可以说是一门语言的"经脉". Go语言中最常用的流程控制有if和for,而switch和goto主要是为了简化代码. ...
- day_4流程控制之分支结构循环结构及for循环
复习一下昨天的内容 1:变量的命名规范 只能由数字 字母 及下划线组成 不能以数字开头 不能与系统关键字重名 _开头有特殊含义 __开头__结尾的变量是魔法变量 支持大小驼峰 ,但建议使用下划线连接语 ...
随机推荐
- CCF真题之字符串匹配
201409-3 问题描述 给出一个字符串和多行文字,在这些文字中找到字符串出现的那些行.你的程序还需支持大小写敏感选项:当选项打开时,表示同一个字母的大写和小写看作不同的字符:当选项关闭时,表示同一 ...
- Servlet里写验证码
public class CodeServlet extends HttpServlet { /** * The doGet method of the servlet. <br> * * ...
- 开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误
已经解决,问题描述:在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.Open() ...
- js break continue
for 循环从 1 到 10 迭代变量 i.在循环主体中,if 语句将(使用取模运算符)检查 i 的值是否能被 5 整除.如果能被 5 整除,将执行 break 语句.alert 显示 "4 ...
- 夺命雷公狗---DEDECMS----21dedecms按照地区取出电影内容
我们现在要做的就是: 这些电影都是要按照地区来取出才可以的,但是我们arclist标签里面有没有按照条件来查找的地方,我们只好换套路了,要不然条条大路都不通,,,, 我们先来构造一条语句: 他这个标签 ...
- scan design rules
为了更好的设计一个scan design,一些scan design的rule必须遵循. 1)tristate bus在shift mode下必须保持bus contention: 2)bidirec ...
- 四则运算GUI版本功能展现
对于四则运算的GUI版本实现支持批量出题,由于我的不积极导致教师没找到对应的连接,现在重新补上链接 http://www.cnblogs.com/liquan/p/5978687.html codin ...
- Test Android with QTP
by Yaron Assa I have recently come across a plug-in to QTP that enables to automate tests on Android ...
- iOS 学习笔记 二 (2015.02.26)
How To Use Git Source Control with Xcode in iOS 6 If you're new here, you may want to subscribe to m ...
- 将linux下的rm命令改造成移动文件至回收站【转】
转自:http://blog.csdn.net/a3470194/article/details/16863803 [-] 将linux下的rm命令改造成移动文件至回收站 将AIX下的rm命令改造成移 ...