当前位置:网站首页>第五章编程题
第五章编程题
2020-11-08 15:22:00 【树莓201杨非凡202005018130】
5.1 ### 时间转换 秒到分钟
#include<stdio.h>
#define p 60
void main()
{
int a, b;
printf("输入时间秒=");
scanf_s("%d", &a);
while (a > 0)
{
printf("%d秒=%d小时%d秒\n", a, a / p, a % p);
printf("输入时间秒=");
scanf_s("%d", &a);
}
}
5.2
按照大小输出所输入的数字到 数字加10
#include<stdio.h>
void main()
{
int a, b;
printf("输入你要的数字: ");
scanf_s("%d", &a);
b = a;
while (b <= a + 10)
{
printf("%d\n", b);
b++;
}
}
5.3
星期转换
#include<stdio.h>
void main()
{
int a, b, c;
printf("输入天数:");
scanf_s("%d", &a);
while (a > 0)
{
printf("%d天=%d周%d天\n", a, a / 7, a % 7);
printf("输入天数:");
scanf_s("%d",& a);
}
}
5.4
身高转换
#include<stdio.h>
void main()
{
float a;
printf("输入你的身高:");
scanf_s("%f", &a);
for (; a > 0;)
{
printf("%.0fcm=%.2f英尺%.2f 英寸\n", a, a / 30.48, a / 2.54);
printf("输入你的身高:");
scanf_s("%d", &a);
}
}
5.5
赚钱计算
#include<stdio.h>
void main()
{
int a, b;
printf("输入 一天赚的钱:\n");
scanf_s("%d", &a);
printf("输入天数:\n");
scanf_s("%d", &b);
printf("一共赚了%d元", a * b);
}
5.6
改进5.5
void main()
{
int b, qian, c;
qian = 0;
printf("输入天数:\n");
scanf_s("%d", &b);
for (c = 1; c <= b; c++)
{
qian = c * c;
printf("第%d天赚了%d\n", c, c * c);
}
}
5.8 求余数
#include<stdio.h>
void main()
{
int a, b, c;
printf("输入鱼数:\n");
scanf_s("%d", &a);
printf("输入被鱼数\n");
scanf_s("%d", &b);
printf("现在被鱼数是:\n", b);
printf("%d 余 %d =%d\n", b,a,b%a);
for (; b > 0;)
{
printf("输入被鱼数\n");
scanf_s("%d", &b);
printf("现在被鱼数是:\n",b );
printf("%d 余 %d =%d\n", b, a, b % a);
}
}
5.9
温度转换
#include<stdio.h>
void main()
{
double a;
printf("输入温度华氏=");
scanf_s("%lf", &a);
printf("摄氏温度为=%.2lf \n开示温度=%.2lf\n", (a - 32) * 5.0 / 9.0, a + 273.16);
while (a > 0 || a <= 0)
{
printf("输入温度华氏=\n");
scanf_s("%lf", &a);
printf("摄氏温度为=%.2lf \n开示温度=%.2lf\n", (a - 32) * 5 / 9.0, a + 273.16);
}
}
/5.9问题 应为已经确定输入值为double型就算输入非数字 也会按照数字存贮 不知道怎么保证 输入为字母时 保证程序正确退出/
一旦输入非数字程序就出错 而且还停不下来 Orz
版权声明
本文为[树莓201杨非凡202005018130]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4743310/blog/4708213
边栏推荐
- 优化if-else代码的八种方案
- I used Python to find out all the people who deleted my wechat and deleted them automatically
- Leancloud changes in October
- DeepMind 最新论文解读:首次提出离散概率树中的因果推理算法
- Q & A and book giving activities of harbor project experts
- Implementation of verification code recognition in Python opencv pytesseract
- 我们做了一个医疗版MNIST数据集,发现常见AutoML算法没那么好用
- Rabbitmq (1) - basic introduction
- Examples of unconventional aggregation
- Rust: performance test criteria Library
猜你喜欢
It's just right. It's the ideal state
小米、OPPO在欧洲市场继续飙涨,小米更是直逼苹果
Examples of unconventional aggregation
STM32CubeIDE下载安装-GPIO基本配置操作-Debug调试(基于CMSIS DAP Debug)
wanxin finance
Learn to record and analyze
Flink从入门到真香(3、从集合和文件中读取数据)
优化if-else代码的八种方案
Interpretation of deepmind's latest paper: the causal reasoning algorithm in discrete probability tree is proposed for the first time
This time Kwai tiktok is faster than shaking.
随机推荐
Tips and skills of CSP examination
Share the experience of passing the PMP examination
Major changes in Huawei's cloud: Cloud & AI rises to Huawei's fourth largest BG with full fire
DeepMind 最新论文解读:首次提出离散概率树中的因果推理算法
阿里撕下电商标签
svg究竟是什么?
阿里云视频云技术专家 LVS 演讲全文:《“云端一体”的智能媒体生产制作演进之路》
Stm32uberide download and install - GPIO basic configuration operation - debug (based on CMSIS DAP debug)
What is SVG?
B站stm32视频学习
On the software of express delivery cabinet and deposit cabinet under Windows
Drink soda, a bottle of soda water 1 yuan, two empty bottles can change a bottle of soda, give 20 yuan, how much soda can you
Golang ICMP协议探测存活主机
三、函数的参数
Blockchain weekly: the development of digital currency is written into the 14th five year plan; Biden invited senior adviser of MIT digital currency program to join the presidential transition team; V
This time Kwai tiktok is faster than shaking.
Huawei has an absolute advantage in the 5g mobile phone market, and the market share of Xiaomi is divided by the market survey organization
PMP experience sharing
刚刚好,才是最理想的状态
优化if-else代码的八种方案