当前位置:网站首页>第五章编程题
第五章编程题
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
边栏推荐
- LeanCloud 十月变化
- Android Basics - check box
- Why is Schnorr Signature known as the biggest technology update after bitcoin segwit
- Python basic syntax
- 浅谈单调栈
- Suitable for C / C + + novice learning some projects, do not give me to miss!
- 用 Python 写出来的进度条,竟如此美妙~
- 三、函数的参数
- Flink from introduction to Zhenxiang (10. Sink data output elasticsearch)
- .NET 大数据量并发解决方案
猜你喜欢
This year's salary is 35W +! Why is the salary of Internet companies getting higher and higher?
Tips and skills of CSP examination
[Python 1-6] Python tutorial 1 -- number
Interpretation of deepmind's latest paper: the causal reasoning algorithm in discrete probability tree is proposed for the first time
AQS解析
我们做了一个医疗版MNIST数据集,发现常见AutoML算法没那么好用
[Python 1-6] Python tutorial 1 -- number
Millet and oppo continue to soar in the European market, and Xiaomi is even closer to apple
Google's AI model, which can translate 101 languages, is only one more than Facebook
PMP experience sharing
随机推荐
软件开发中如何与人协作? | 每日趣闻
【Python 1-6】Python教程之——数字
The birth of a new integrated memory and computing chip is conducive to the application of artificial intelligence~
Do these mistakes in your resume affect your annual salary of one million?
金融领域首个开源中文BERT预训练模型,熵简科技推出FinBERT 1.0
PMP experience sharing
This paper analyzes the top ten Internet of things applications in 2020!
一文读懂机器学习“数据中毒”
Alibaba cloud accelerates its growth and further consolidates its leading edge
Android Basics - check box
新型存算一体芯片诞生,利好人工智能应用~
漫画|讲解一下如何写简历&项目
Is there no way out for older programmers?
小青台正式踏上不归路的第3天
CSP考试须知与各种小技巧
. net large data concurrency solution
This year's salary is 35W +! Why is the salary of Internet companies getting higher and higher?
On monotonous stack
Workers, workers soul, draw lifelong members, become a person!
How to make a correct summary for 7 years?