随笔分类 - C语言填空
摘要://下面程序的运行结果为_______________。 #include"stdio.h" main( ) { int a=3,b=5,c=8; if(a++<3 && c--!=0) b=b+1; printf("a=%d,b=%d,c=%d\n",a,b,c); } a=4,b=5,c=8
阅读全文
摘要://程序的功能是实现表达式z=( x>=y ? x : y),请将程序填写完整。 #include <stdio.h> main() { int x, y, z; printf("Please input x,y:"); scanf("%d%d",【1】); if 【2】 z=x; else 【3】
阅读全文
摘要:#include<stdio.h> //判断指定字符是数字还是小写字母或大写字母或其他字符 main() {【1】 ch; printf("请输入一个字符"); scanf("【1】",【1】); if(【1】) printf("%c是大写字母",ch); else if(【1】) printf("
阅读全文
摘要:#include<stdio.h> //输入一元二次方程的系数a,b,c,判断是否有解,有几个解 main() {【1】 a,b,c,dt; printf("请输入一个a,b,c的值,a不能为0\n"); scanf("%f %f %f",【2】); dt=【3】; if(【4】) printf("
阅读全文
摘要:#include<stdio.h> //水仙花数:三位数的每个数字的立方和等于这个数, 判断某数是不是水仙花数 main() {【1】; printf("请输入一个水仙花数"); scanf("%d",【2】); g=【3】; s=【4】; b=【5】; if(【6】==x) printf("%d是
阅读全文
摘要://任意输入三角形三边长,判断能否组成三角形,并求面积 【1】 【2】 main() {【3】 a,b,c,p,s; scanf("【4】",&a,&b,&c); if(【5】) {p=1/【6】*(a+b+c); s=sqrt(【7】); printf("三角形的面积是%f",s); } else
阅读全文
摘要:#include<stdio.h> main() {int x; printf("请输入一个整数"); scanf("%d",【1】); if(【1】) printf("%d能被3整除",x); else printf("%d不能被3整除",x); } #include<stdio.h> main(
阅读全文
摘要:#include<stdio.h> //判断指定年份是闰年还是平年 main() {int year; printf("请输入年数"); scanf("%d",【1】); if(【2】) printf("%d年是闰年",year); else if(year%【3】==0) printf("%d年是
阅读全文
摘要:/*输入日期,输出该天是该年的第几个。*/ #include<stdio.h> main() { int a,b,c,s=0; printf("请输入一个日期"); scanf("%d.%d.%d",&a,&b,&c); if(b==1) 【1】; if(b>1) s=s+31+c; if(b>2)
阅读全文
摘要:/*输入时间XX:XX:XX,输出一秒后对应的时间*/ #include<stdio.h> main() { int a,b,c; printf("请输入时间,格式为XX:XX:XX\n"); scanf("%d:%d:%d",&a,&b,&c); c++; if(【1】) { c=0; 【2】;
阅读全文
摘要:/*设圆半径r=1.5,圆柱高h=3,求圆周长,圆面积,圆球表面积,圆球体积,圆柱体积 用scanf输入数据,输出计算结果,输出时要求有文字说明,取小数后2位数字 球表面积公式 s=4*PI*r*r 球体积公式 v=4*pI*r*r/3 */ #include <stdio.h> 【7】 PI 3.
阅读全文
摘要:/*假设今天是星期日,编写一个程序,求123456天后是星期几*/ #include<stdio.h> int main() { int n,iday; printf("请输入天数:"); scanf("%d",【1】); 【2】; switch(【3】) { case 0:printf("%d天后
阅读全文
摘要:/*输入的一个小写字母,将字母循环后移5个位置后输出。如 ’a’ 将输出为 ‘f’ ,’w’ 输出为 ‘b’ 。 要求有输入提示"请输入一个小写字母:",若输入的不是小写字母,提示“输入非法”。*/ #include<stdio.h> main() { char ch; printf("请输入一个小
阅读全文
摘要:/*今有鸡兔同笼,上有三十五头,下有九十四足,问鸡兔各几何? */ /*在一个笼子里养着一些鸡和兔子,你想了解有多少只鸡和兔子。主人对你说: 鸡和兔子总头数是16和脚总数是40,你能自己计算有多少只鸡和兔子来吗?,如果不存在则输出无解*/ #include <stdio.h> main() { in
阅读全文
摘要:/* 从键盘输入两个时间点(24小时制),输出两个时间点之间的时间间隔,时间间隔用 “小时:分钟:秒 ”表示,如3点5分25秒表示为03:05:25.假设两个时间在同一天内,时间先后顺序与输入无关。 如:输入12:01:12 13:09:43 输出结果为 01:08:31 */ #include<s
阅读全文
摘要:/* 编写一个简单的计算器程序,输入格式为:data1 op data2是参加运算的两个数, op为运算符,它的取值只能是+、-、*/ #include<stdio.h> main() { int data1,data2; char op; scanf("%d%c%d",【1】); switch(【
阅读全文
摘要:/*假设今天是星期天,编写程序,求1、2、3、4、5、6天后 是星期几(用英文)? */ #include <stdio.h> main() { char 【1】; int xh; scanf("%d",【2】); printf("%d天后是%s",xh,【3】); } /*假设今天是星期天,编写程
阅读全文
摘要:/*注册输入名字,密码;名字只能是英文字母,密码只能是数字,已经有人注册名字U,用户名不能重复, 输入密码判断正确错误 ,再次输入密码判断。如两次密码一样,输出密码 */ #include<stdio.h> main() {char yhm,m1,m2; printf("输入用户名:"); scan
阅读全文
摘要:/* 输入三个整数,找出期中的中间数(这里的中间数指的是大小不是位置)*/ #include<stdio.h> main() { int a,b, c,max,min,mid; scanf("%d %d %d",&a,&b,&c); if(a>b) {max=a;【1】; } else {max=b
阅读全文
摘要:/*输入年号和月份,判断该年是否为闰年,并根据给出的月份判断是什么季节和该月有多少天? 闰年的条件是年号能被4整除但不能被100 整除或者能被400整除 3月-5月为春季,6月-8月为夏季 9月-11月为秋季 12月-2月为冬季*/ #include<stdio.h> main() { int y,
阅读全文