1/28 if
2016-01-28 15:52
344 查看
#include <stdio.h> // judge the number whether can be divisible by 3 or 5 int main() { printf("judge the number a ,whether can be divisible by 3 or 5\n"); int a; scanf("%d",&a); int b,c; b=a%3; c=a%5; if ((b==0)||(c==0)) { printf("%d\n",a); } return 0; }
#include <stdio.h> //if a+b<100 print a+b //if a+b>100 print a+b>=10^2 int num_100above(int a) { int b; b=a/10; return b; } int main() { printf("please insert a and b\n"); int a,b; scanf("%d %d",&a,&b); if(a+b<=100) { printf("%d",a+b); } else { printf("%d",num_100above(a+b)); } return 0; }
#include <stdio.h> //calculate y=x-1(x>=1) //y=-x+1(x<1) int main() { printf("insert x\n"); int x,y; scanf("%d",&x); if(x>=1) { y=x-1; } else { y=-x+1; } printf("%d\n",y); return 0; }
#include <stdio.h> #include <math.h> double yx(double x) { double y; if(x>=0) { y=(sin(x)+cos(x))/2.0; } else { y=(sin(x)-cos(x))/2.0; } return y; } int main() { double y,x; printf("insert x\n"); scanf("%lf",&x); y=yx(x); printf("%f",y); return 0; }
#include <stdio.h> //calculate salary //h=40 //if h=40 salary=rate*hour //if h>=40 addition=rate*1.5*addhours int main() { int rate,hours,addhours; double salary; printf("insert rate and hours\n"); scanf("%d %d",&rate,&hours); if(hours<=40) { salary=rate*hours; } else { addhours=hours-40; salary=40*rate; salary=salary+addhours*1.5*rate; } printf("salary is %f\n",salary); return 0; }
#include <stdio.h> int main() { printf("please insert hours and minutes\npay attention to sequence\n"); int hours,minutes; scanf("%d %d",&hours,&minutes); if(hours<=9) { printf("0"); } printf("%d:",hours); if(minutes<=9) { printf("0"); } printf("%d\n",minutes); return 0; }
相关文章推荐
- 21-修改表给mysql添加外键
- Java基础-了解HashSet
- 判断一个字符串是否为数值型字符串
- 如何实现QML中的pathview
- 接口和抽象类有什么区别
- Eclipse Ctrl+Space 无法工作的问题
- 【SDOI2014】数数
- HTML meta标签总结与属性的使用介绍
- IIS Express
- 解决yum升级的问题“There was a problem importing one of the Python modules”
- JSON 解析(2)
- JSON 格式(1)
- 可模拟手机,导入apk即可
- 获取checkbox 的选中状态的id、checkbox的一些操作
- Spring Data JPA 的配置文件 已经数据库的状态
- 网站设置实体类属性的一种方式
- Tomcat性能调优-让小猫飞奔
- codeforces 620e
- QT Creator 如何将第三方库加入到环境内
- 技术人员怎样转型成为产品经理?