当前位置:网站首页>第五章编程题
第五章编程题
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
边栏推荐
- rabbitmq(一)-基础入门
- I used Python to find out all the people who deleted my wechat and deleted them automatically
- [Python 1-6] Python tutorial 1 -- number
- AI weekly: employees are allowed to voluntarily reduce salary; company response: employees are happy and satisfied; tiger tooth HR takes employees out of the company; Sweden forbids Huawei ZTE 5g equi
- 软件开发中如何与人协作? | 每日趣闻
- Improvement of rate limit for laravel8 update
- This time Kwai tiktok is faster than shaking.
- 3、 The parameters of the function
- Flink从入门到真香(3、从集合和文件中读取数据)
- 一文剖析2020年最火十大物联网应用|IoT Analytics 年度重磅报告出炉!
猜你喜欢

别再在finally里面释放资源了,解锁个新姿势!

数据库连接报错之IO异常(The Network Adapter could not establish the connection)

我用 Python 找出了删除我微信的所有人并将他们自动化删除了

漫画:寻找股票买入卖出的最佳时机(整合版)

Major changes in Huawei's cloud: Cloud & AI rises to Huawei's fourth largest BG with full fire

Or talk No.19 | Facebook Dr. Tian Yuandong: black box optimization of hidden action set based on Monte Carlo tree search

Don't release resources in finally, unlock a new pose!

Arduino ide build esp8266 development environment, slow file download solution | esp-01 make WiFi switch tutorial, transform dormitory lights

模板引擎的整理归纳

Xiaoqingtai officially set foot on the third day of no return
随机推荐
Solution of DEV-C + + unable to debug in Windows Environment
LeanCloud 十月变化
阿里撕下电商标签
【Python 1-6】Python教程之——数字
原创 | 数据资产确权浅议
京东落地DevOps平台时爆发的冲突如何解决?
The progress bar written in Python is so wonderful~
新型存算一体芯片诞生,利好人工智能应用~
Returning to the third place in the world, what did Xiaomi do right?
svg究竟是什么?
Golang ICMP协议探测存活主机
How to write a resume and project
Python basic syntax
软件开发中如何与人协作? | 每日趣闻
GopherChina 2020大会
【Python 1-6】Python教程之——数字
Suitable for C / C + + novice learning some projects, do not give me to miss!
基于阿里云日志服务快速打造简版业务监控看板
Don't release resources in finally, unlock a new pose!
阿里云的MaxCompute数加(原ODPS)用的怎样?