当前位置:网站首页>第五章编程
第五章编程
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
边栏推荐
猜你喜欢
Five design schemes of singleton mode
[200 interview experience], programmer interview, common interview questions analysis
The interface testing tool eolinker makes post request
Test comparison of three domestic cloud databases
CMS垃圾收集器
寻找性能更优秀的不可变小字典
Classical dynamic programming: longest common subsequence
Newbe.ObjectVisitor 样例 1
Copy the picture
SQL语句的执行
随机推荐
Dynamic programming: maximum subarray
Computer network application layer
Part 1 - Chapter 2 pointer operation
第五章
Python features and building environment
Solve the problem that the value of new date() of JS in IE and Firefox is invalid date and Nan Nan
AQS 都看完了,Condition 原理可不能少!
Database design: paradigms and anti paradigms
如何通过Sidecar自定义资源减少Istio代理资源消耗
云计算之路-出海记-小目标:Hello World from .NET 5.0 on AWS
使用递增计数器的线程同步工具 —— 信号量,它的原理是什么样子的?
Python的特性与搭建环境
当我们聊数据质量的时候,我们在聊些什么?
Python应用场景多不多?
【云服务】阿里云服务器ECS实例规格那么多,如何选型?最佳实践说明
寻找性能更优秀的动态 Getter 和 Setter 方案
C/C++编程笔记:指针篇!从内存理解指针,让你完全搞懂指针
都说程序员钱多空少,程序员真的忙到没时间回信息了吗?
大数据岗位基础要求有哪些?
What are the basic requirements for big data posts?