习题5
来源:互联网 发布:移动硬盘合并分区软件 编辑:程序博客网 时间:2024/04/29 02:44
5.1 绝对值的输出
#include <stdio.h>#include <stdlib.h>int main(){ int x; printf ("请输入一个实数 x:"); scanf ("%d",&x); if (x>=0) printf ("输出x的绝对值 %d\n",x); else printf ("输出x的绝对值 %d\n",x=-(x),x); return 0;}
5.2 判断奇偶性
#include <stdio.h>#include <stdlib.h>int main(){ int x; printf ("请输入任意一个整数x:"); scanf ("%d",&x); if (x%2==0) printf ("偶数"); else printf ("奇数"); return 0;}
5.3 判断三角形是否构成
#include <stdio.h>#include <stdlib.h>int main(){ int a,b,c,s,p; printf ("请输入任意三角形的三条边a,b,c:"); scanf ("%d%d%d",&a,&b,&c); if (a+c>b && a+b>c && b+c>a) p=(a+b+c)\2; s=sqrt[p(p-a)(p-b)(p-c)]; printf ("能构成三角形 面积为s=%d\n"s); else printf ("不能构成三角形"); return 0;}
5.4 利息与本金合计
#include <stdio.h>#include <stdlib.h>int main(){ int n,b; float h; printf ("请输入本金b和期限n:"); scanf ("%d%d",&b,&n); if (n==1) { h=b+b*0.0225; printf ("利息与本金的合计h=%f\n",h); } if (n==2) { h=b+b*0.0243*n; printf ("利息与本金的合计h=%f\n",h); } if (n==3) { h=b+b*0.027*n; printf ("利息与本金的合计h=%f\n",h); } if (n>3 && n<=8) { h=b+b*0.0288*n; printf ("利息与本金的合计h=%f\n",h); } if (n==8) { h=b+b*0.03*n; printf ("利息与本金的合计h=%f\n",h); } return 0;}
5.5
#include <stdio.h>#include <stdlib.h>int main(){ int year,flag; printf ("Enter year:"); scanf ("%d",&year); if (year%4==0 && year%100!=0) flag=1; else flag=0; if (year%400==0) printf ("%d is a leap year!\n",year); else printf ("%d is not a leap year !\n",year); return 0;}
5.9
#include <stdio.h>#include <stdlib.h>int main(){ int score; printf ("请输入分数score:"); scanf ("%d",&score); if (score<=100 && score>=90) printf ("A:"); if (score<90 && score>=80) printf ("B:"); if (score<80 && score>=70) printf ("C:"); if (score<70 && score>=60) printf ("D:"); if (score<60 && score>=0) printf ("E:"); return 0;}
阅读全文
0 0
- 习题 5:
- 习题5
- 习题5
- 习题5
- 习题5
- 习题5
- 课后习题 5_5
- 内部类习题5
- 汇编--5章习题
- 习题1-5,距离
- 习题2-5,统计
- 习题3-5,旋转
- 课后习题9--5
- Chap 5 习题解答
- 习题2-5 统计
- 习题1—5
- 习题1-5
- 习题 1-5 打折
- 微信错误代码:errcode:{40055} errmsg:{invalid button url domain}
- Excel插入多个空行
- Java继承与多态之转型
- 文章标题
- 图分析中的统计和中心度量算法表
- 习题5
- 搭建简单的typescript测试框架
- 最大公约数
- COCOS2D-X字体描边
- c语言获取用户输入字符串是scanf和gets的区别
- 长征精神演讲稿
- Struts2第一天(入门)
- 习题5.1
- 最大公约数