当前位置:网站首页>第五章编程
第五章编程
2020-11-08 23:53:00 【Cx330】
**2 打印数值**
#include<stdio.h>
int main()
{
int a, b;
printf("输入你要的数字: ");
scanf("%d", &a);
b = a;
while (b <= a + 10)
{
printf("%d\n", b);
b++;
}
}
````
** 3 天换周**
#include <stdio.h>
int main()
{
int a, b, c;
printf("请输入天数:");
scanf("%d", &a);
printf("%d天=%d周%d天\n", a, a / 7, a % 7);
return 0;
}
````
** 4 身高转换 **
#include <stdio.h>
#define a 30.48
#define b 2.54
int main()
{
int feet;
float inches, cm;
printf("CONVERT CM TO INCHES!\n");
printf("Enter the hight in centimeters:");
scanf("%f", &cm);
while (cm > 0) {
feet = cm / a;
inches = (cm - feet * a / b);
printf("%.1fcm=%dfeet,%.1f inches\n", cm, feet,inches);
printf("Enter the hight in centimeters(<=0 to quit):");
scanf("%f", &cm);
}
printf("PROGRAM EXIT!\n");
return 0;
}
5 赚钱
#include<stdio.h>
int main()
{
int a, b; printf("输入一天赚的钱:\n");
scanf("%d", &a);
printf("输入天数:\n");
scanf("%d", &b);
printf("一共赚了%d元", a * b);
}
**8 求模运算**
#include<stdio.h>
int main(int argc, char* argv[])
{
int first, second;
printf("This program computers moduli.\n");
printf("Enter an integer to server as the second operand:");
scanf("%d", &second);
printf("now enter the first operand:");
scanf("%d", &first);
while (first > 0) {
printf("%d %% %d is %d\n", first, second);
printf("Enter next number for first operand:");
scanf("%d", &first);
}
printf("done!\n");
return 0;
}
#include <stdio.h>
int T(double fahrenheit);
int main(int arge, char* argv[])
{
double input;
printf("This program convert fahrenheit to celsius and kelvin.\n");
printf("Enter a fahrenheit to start:");
while (scanf("%1f",&input) == 1) {
T(input);
printf("Enter next fahrenheit!:");
}
printf("Done!\n");
return 0;
}
int T(double fahrenheit) {
const double FC = 32.0;
const double CK = 273.16;
double celsius, kelvin;
celsius = 5.0 / 9.0 * (fahrenheit - FC);
kelvin = celsius + CK;
printf("%.2f.fahrenheit,equal %.2f celsius, and %.2f kelvin\n", fahrenheit, celsius,kelvin);
return 0;
}
版权声明
本文为[Cx330]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4761328/blog/4708369
边栏推荐
- 如何将 PyTorch Lightning 模型部署到生产中
- Introduction skills of big data software learning
- Part 1 - Chapter 2 pointer operation
- API生命周期的5个阶段
- Aprelu: cross border application, adaptive relu | IEEE tie 2020 for machine fault detection
- 通过canvas获取视频第一帧封面图
- Octave basic syntax
- Decorator (1)
- SAP S/4HANA 2020安装实录
- centos7下安装iperf时出现 make: *** No targets specified and no makefile found. Stop.的解决方案
猜你喜欢
Test comparison of three domestic cloud databases
存储过程动态查询处理方法
Introduction skills of big data software learning
Five phases of API life cycle
Programmers should know the URI, a comprehensive understanding of the article
服务器性能监控神器nmon使用介绍
大数据岗位基础要求有哪些?
SAP S/4HANA 2020安装实录
Copy the picture
Introduction and application of swagger
随机推荐
数组初相识
JVM Zhenxiang series: easy understanding of class files to virtual machines (Part 2)
CMS垃圾收集器
leetcode之反转字符串中的元音字母
信息安全课程设计第一周任务(7条指令的分析)
Classical dynamic programming: longest common subsequence
老大问我:“建表为啥还设置个自增 id ?用流水号当主键不正好么?”
单例模式的五种设计方案
【云服务】阿里云服务器ECS实例规格那么多,如何选型?最佳实践说明
简单介绍c#通过代码开启或关闭防火墙示例
基于链表的有界阻塞队列 —— LinkedBlockingQueue
API生命周期的5个阶段
Database design: paradigms and anti paradigms
Experiment 1 assignment
[200 interview experience], programmer interview, common interview questions analysis
Array acquaintance
How to analyze Android anr problems
如何将 PyTorch Lightning 模型部署到生产中
计算机网络 应用层
动态规划设计:最大子数组