当前位置:网站首页>第五章编程题
第五章编程题
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
边栏推荐
- On the confirmation of original data assets
- 别再在finally里面释放资源了,解锁个新姿势!
- svg究竟是什么?
- Share the experience of passing the PMP examination
- 用科技赋能教育创新与重构 华为将教育信息化落到实处
- Q & A and book giving activities of harbor project experts
- Powershell 使用.Net对象发送邮件
- 三、函数的参数
- Returning to the third place in the world, what did Xiaomi do right?
- python基础教程python opencv pytesseract 验证码识别的实现
猜你喜欢
Dev-c++在windows环境下无法debug(调试)的解决方案
. net large data concurrency solution
我用 Python 找出了删除我微信的所有人并将他们自动化删除了
Examples of unconventional aggregation
Flink从入门到真香(6、Flink实现UDF函数-实现更细粒度的控制流)
Powershell 使用.Net对象发送邮件
Tight supply! Apple's iPhone 12 power chip capacity exposed
Flink: from introduction to Zhenxiang (6. Flink implements UDF function - realizes more fine-grained control flow)
Windows下快递投递柜、寄存柜的软件初探
Comics: looking for the best time to buy and sell stocks
随机推荐
How to make a correct summary for 7 years?
Talking about, check the history of which famous computer viruses, 80% of the people do not know!
I used Python to find out all the people who deleted my wechat and deleted them automatically
The network adapter could not establish the connection
新型存算一体芯片诞生,利好人工智能应用~
LeanCloud 十月变化
漫画:寻找股票买入卖出的最佳时机(整合版)
PMP考试通过心得分享
Restfulapi learning notes -- father son resources (4)
WLAN 直连(对等连接或 P2P)调研及iOS跨平台调研
Tips and skills of CSP examination
PMP experience sharing
Python basic syntax
这次,快手终于比抖音'快'了!
Stm32uberide download and install - GPIO basic configuration operation - debug (based on CMSIS DAP debug)
On monotonous stack
Suitable for C / C + + novice learning some projects, do not give me to miss!
Implementation of verification code recognition in Python opencv pytesseract
[Python 1-6] Python tutorial 1 -- number
Millet and oppo continue to soar in the European market, and Xiaomi is even closer to apple