1.1 顺序结构 参考代码

P1001 A+B Problem

#include <cstdio>
int main()
{
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", a + b);
return 0;
}

P5703 [深基2.例5] 苹果采购

#include <cstdio>
int main()
{
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", a * b);
return 0;
}

P5704 [深基2.例6] 字母转换

#include <cstdio>
int main()
{
char ch;
scanf("%c", &ch);
printf("%c\n", ch - 'a' + 'A');
return 0;
}

P5705 [深基2.例7] 数字反转

#include <cstdio>
int main()
{
char a, b, c, d, e;
scanf("%c%c%c%c%c", &a, &b, &c, &d, &e);
printf("%c%c%c%c%c\n", e, d, c, b, a);
return 0;
}

P5706 [深基2.例8] 再分肥宅水

#include <cstdio>
int main()
{
double t;
int n;
scanf("%lf%d", &t, &n);
printf("%.3f\n%d\n", t / n, 2 * n);
return 0;
}

P1425 小鱼的游泳时间

#include <cstdio>
int main()
{
int a, b, c, d;
scanf("%d%d%d%d", &a, &b, &c, &d);
int t = c * 60 + d - (a * 60 + b);
printf("%d %d\n", t / 60, t % 60);
return 0;
}

P1421 小玉买文具

#include <cstdio>
int main()
{
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", (a * 10 + b) / 19);
return 0;
}

P3954 [NOIP2017 普及组] 成绩

#include <cstdio>
int main()
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
printf("%d\n", a / 5 + b / 10 * 3 + c / 2);
return 0;
}
  • 能用整数运算完成的尽量用整数去实现

P5707 [深基2.例12] 上学迟到

#include <cstdio>
int main()
{
int s, v;
scanf("%d%d", &s, &v);
int cnt = (s + v - 1) / v;
cnt += 10;
int t = (480 - cnt + 1440) % 1440;
printf("%02d:%02d\n", t / 60, t % 60);
return 0;
}
posted @   RonChen  阅读(35)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 【杂谈】分布式事务——高大上的无用知识?
点击右上角即可分享
微信分享提示