当前位置:网站首页>习题五
习题五
2020-11-08 16:22:00 【S菜鸟程序猿S】
第一题
/*huang
*/
#iinclude<stdio.h>
#define MIN_PER_HOU 60 //每小时有60分钟
int main (int argc,char *argv[]){
int hours, minutes, input;
printf("CONVERT MINUTES TO HOURS!\n");
printf("PLEASE INPUT THE NUMBER OF MINNUTES(<=0 TO QUIT):“);
scanf("%d",&input);
while(input >0){
hours=input/MIN_PRT_HOU:
printf("CONVERT TO %d HOUT AND %dMINUTES\n",houts,minutes);
printf("PLEASE CONTINUE INPUT UHE NUMBER OF MINUTES (<=0TO QUIT):");
scant("%d",&input);
}
printf("PROGRAM EXIT!\n");
}
第二题
/*huang
*/
#include<stdio.h>
int main(int rgc,char *argv[]){
int counter,i=0;
printf("PRINT COUNTINUE 10 NUMBERS!\n");
printf("PLEASE INPUT THESTART NUMBER :");
scanf("%d",&counter);
while(i+<11){
printf("%d\n",counter++);
printf("PROGRAM EXIT!\n");
returen 0;
}
第三题
/*huang
*/
#include<stdio.h。
#define WEEK_PER_DAY 7//每周有7天
int main (int argc,char*argv[]){
int daysmweeks,input;
printf("CONVERT FAYS TO WEEKS!\n");
printf("PLEASE INPUT THE NUMBER OF DAYS (<=0 TO QUIT):");
scanf("%d",&input);
while (input>0){
weeks=input/WEEK_PER_DAY;
days=input%WEEKK_PER_DAY;
printf("%d days are %d weeks, %d days\n",input,weeks,days);
printf("PLEASE INPUT THE NUMBER OF DAYS(<=0 TO QUIT):");
scanf("%d",&input);
}
printf("PROGRAM EXIT!\n");
return 0;
}
第四题
/*huang
*/
#include<stdio.h>
#define FEET_TO_CM 30.48
#define INCH_TO_CM 2.54
int main (int argc, char*argv[]){
int feet;
float inches,cm;
printf("CONVERT CM TO INCHES!\n");
printf("Enter the height in centimeters:");
scanf("%f",&cm);
while (cm>0){
feet=cm/FEET_TO_CM;
inches=(cm -feet*FEET_TO_CM)/INCH_TO_CM;
printf("%.1f cm=%d feet , %.1f inches\n",cm,feet,inches);
printf("Enter the height in centimeters(<=0 TO QUIT):");
scanf(‘%f",&cm);
}
printf("PROGRAM EXIT!\n);
return 0;
}
第五题
/*huang
*/
#include<stdio.h>
int main(int argc,char *argv[]){
int count = 0,sum=0;
printf("Enter the number of days you work:");
scanf ("%d",&count);
while(count>o){
sum=sum+count--;
}
printf("You earned $ %d total!\n",sum);
printf("PROGRAM EXIT !\n");
return 0;
}
第六题
/*huang
*/
#include<stdio.h>
int main(int argc,char *argv[){
int count=0,sum=0;
printf("Enter the number of fays you work:");
scanf("%d",&count);
while(count>0){
sum=sum+count * count;
count--;
}
printf("You earned $ %d total!\n",sum);
printf("PROGAM EXIT!\n");
return 0;
}
第七题
/*huang
*/
#include<stdio.h>
double cubic(double n);
int main(int argc,char *argv[]){
double input;
printf("Enter the double datum to calc cubic :");
scanf("%f",&input);
cubic(inrut);
printf("PROGRAM EXIT!\n");
return 0;
}
double cubic(double n){
double t=n*n*n;
printf("The %1g's cubic is %1g !\n",n,t);;
return t;
}
第八题
/*huang
*/
#include<stdio.h>
int main (int argc,char *argv[]){
int first,second;
printf("This program computes 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,(first%second));
printf("Enter next number for first operand(<=0 to quit):");
scanf("%d",&first);
}
printf("Done!\n");
return 0;
}
第九题
/*huang
*/
#include<stdio.h>
int Temperatures(douuble fahrenheit);
int main(int argc,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){
Temperatures(input);
printf("Enter next fahrenheit!(q to quit):");
}
printf("Done!\n");
return 0;
}
int Temperatures(double fahrenheit){
const double F_TO_C = 32.0;
const double C_TO_K = 273.16;
celsius = 5.0/9.0*(fahrenheit - F_TO_C);
kelvin = celsius + C_TO_K;
printf("%.2,fahrennheit, equal %.2f celsius, and %.2f kelvin\n",fahrenheit,
return 0;
}
版权声明
本文为[S菜鸟程序猿S]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4741327/blog/4708232
边栏推荐
- SQL 速查
- Talk about go code coverage technology and best practices
- 金融领域首个开源中文BERT预训练模型,熵简科技推出FinBERT 1.0
- 总结: 10月海外DeFi新项目,更多资管策略来了!
- 一分钟全面看懂forsage智能合约全球共享以太坊矩阵计划
- How does Alibaba cloud's maxcompute add (original ODPs) work?
- Talking about, check the history of which famous computer viruses, 80% of the people do not know!
- 漫画:寻找股票买入卖出的最佳时机(整合版)
- The network adapter could not establish the connection
- 谷歌开源能翻译101种语言的AI模型,只比Facebook多一种
猜你喜欢
Do these mistakes in your resume affect your annual salary of one million?
Builder pattern
阿里云视频云技术专家 LVS 演讲全文:《“云端一体”的智能媒体生产制作演进之路》
GopherChina 2020大会
关于adb连接手机offline的问题解决
打工人,打工魂,抽终身会员,成为人上人!
Design by contract (DBC) and its application in C language
Solution of DEV-C + + unable to debug in Windows Environment
构建者模式(Builder pattern)
关于update操作并发问题
随机推荐
RestfulApi 学习笔记——父子资源(四)
API生命周期的5个阶段
2035我们将建成这样的国家
Development of uni app imitating wechat app
Talk about go code coverage technology and best practices
Returning to the third place in the world, what did Xiaomi do right?
AI周报:允许“员工自愿降薪”;公司回应:员工内心高兴满意;虎牙HR将员工抬出公司;瑞典禁用华为中兴5G设备
重返全球第三,小米做对了什么?
How does Alibaba cloud's maxcompute add (original ODPs) work?
LeanCloud 十月变化
函数分类大pk!sigmoid和softmax,到底分别怎么用?
Leancloud changes in October
markdown使用
Solution to the problem of offline connection between ADB and mobile phone
Using k3s to create local development cluster
构建者模式(Builder pattern)
Arduino ide build esp8266 development environment, slow file download solution | esp-01 make WiFi switch tutorial, transform dormitory lights
DeepMind 最新论文解读:首次提出离散概率树中的因果推理算法
What is SVG?
阿里云的MaxCompute数加(原ODPS)用的怎样?