当前位置:网站首页>第五章编程题
第五章编程题
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
边栏推荐
- 10 common software architecture patterns
- 一文读懂机器学习“数据中毒”
- From a friend recently Ali, Tencent, meituan and other P7 Python development post interview questions
- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水
- Arduino ide build esp8266 development environment, slow file download solution | esp-01 make WiFi switch tutorial, transform dormitory lights
- 阿里撕下电商标签
- Tight supply! Apple's iPhone 12 power chip capacity exposed
- 优化if-else代码的八种方案
- I used Python to find out all the people who deleted my wechat and deleted them automatically
- C++的那些事儿:从电饭煲到火箭,C++无处不在
猜你喜欢

Build simple business monitoring Kanban based on Alibaba cloud log service

浅谈,盘点历史上有哪些著名的电脑病毒,80%的人都不知道!

Workers, workers soul, draw lifelong members, become a person!

Flink: from introduction to Zhenxiang (3. Reading data from collection and file)

华为在5G手机市场占据绝对优势,市调机构对小米的市占出现分歧

Improvement of maintenance mode of laravel8 update

Enabling education innovation and reconstruction with science and technology Huawei implements education informatization

Suitable for C / C + + novice learning some projects, do not give me to miss!

Google's AI model, which can translate 101 languages, is only one more than Facebook

Flink: from introduction to Zhenxiang (6. Flink implements UDF function - realizes more fine-grained control flow)
随机推荐
Major changes in Huawei's cloud: Cloud & AI rises to Huawei's fourth largest BG with full fire
阿里云加速增长,进一步巩固领先优势
[Python 1-6] Python tutorial 1 -- number
技术总监7年总结,如何进行正确的沟通?
Millet and oppo continue to soar in the European market, and Xiaomi is even closer to apple
软件开发中如何与人协作? | 每日趣闻
Python基础语法
Share the experience of passing the PMP examination
小米、OPPO在欧洲市场继续飙涨,小米更是直逼苹果
nat转换的ip跟端口ip不相同的解决方法
用科技赋能教育创新与重构 华为将教育信息化落到实处
The network adapter could not establish the connection
擅长To C的腾讯,如何借腾讯云在这几个行业云市场占有率第一?
Implementation of verification code recognition in Python opencv pytesseract
svg究竟是什么?
How to solve the conflict when JD landed on Devops platform?
供货紧张!苹果被曝 iPhone 12 电源芯片产能不足
Rabbitmq (1) - basic introduction
Research on WLAN direct connection (peer-to-peer connection or P2P) and cross platform research of IOS
Enabling education innovation and reconstruction with science and technology Huawei implements education informatization