当前位置:网站首页>第五章编程
第五章编程
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
边栏推荐
- 代码保存
- Web上的分享(Share)API
- SQL语句的执行
- 200人的程序员面试经验,都在这里了
- 你有没有想过为什么交易和退款要拆开不同的表
- Dynamic relu: Microsoft's refreshing device may be the best relu improvement | ECCV 2020
- 非阻塞的无界线程安全队列 —— ConcurrentLinkedQueue
- Decorator (1)
- 如何将 PyTorch Lightning 模型部署到生产中
- The road of cloud computing - going to sea - small goal: Hello world from. Net 5.0 on AWS
猜你喜欢
随机推荐
The interface testing tool eolinker makes post request
JVM Zhenxiang series: easy understanding of class files to virtual machines (Part 2)
Deep copy
Test comparison of three domestic cloud databases
Factory pattern pattern pattern (simple factory, factory method, abstract factory pattern)
C/C++学习日记:原码、反码和补码
Mobile big data own website precise marketing and accurate customer acquisition
如何通过Sidecar自定义资源减少Istio代理资源消耗
基于链表的有界阻塞队列 —— LinkedBlockingQueue
Tasks of the first week of information security curriculum design (analysis of 7 instructions)
[200 interview experience], programmer interview, common interview questions analysis
教你如何 分析 Android ANR 问题
Copy the picture
APReLU:跨界应用,用于机器故障检测的自适应ReLU | IEEE TIE 2020
Execution of SQL statement
梁老师小课堂|谈谈模板方法模式
Iterm2 configuration and beautification
LeetCode 45 跳跃游戏II
第一部分——第2章指针操作
APP 莫名崩溃,开始以为是 Header 中 name 大小写的锅,最后发现原来是容器的错!