//第一题
#include<stdio.h>
#define minutes_to_hours 60
int main()
{
int minutes;
scanf("%d",&minutes);
while(minutes>0){
printf("Your minutes is %d hours %d minutes\n",minutes/minutes_to_hours,minutes%minutes_to_hours);
printf("Please enter another minutes\n");
scanf("%d",&minutes);
}
printf("Done!");
}
//第二题
#include<stdio.h>
int main()
{
int number;
printf("Please enter a number:\n");
scanf("%d",&number);
int i;
for(i=0;i<=10;i++){
printf("%d ",number+i);
}
}
//第三题
#include<stdio.h>
#define days_to_weeks 7
int main()
{
int days;
printf("Please enter the days:\n");
scanf("%d",&days);
while(days>0){
printf("%d days are %d weeks,%d days:\n",days,days/days_to_weeks,days%days_to_weeks);
printf("Please enter another days\n");
scanf("%d",&days);
}
}
//第四题
#include<stdio.h>
#define height_cm_to_height_feet 30.48
#define height_cm_to_height_inches 2.54
int main()
{
double height_cm;
printf("Please enter your height(centimeters):\n");
scanf("%lf",&height_cm);
int height_feet=(int)height_cm/height_cm_to_height_feet;
double height_inches=(height_cm-height_feet*height_cm_to_height_feet)/height_cm_to_height_inches;
while(height_cm>0){
int height_feet=(int)height_cm/height_cm_to_height_feet;
double height_inches=(height_cm-height_feet*height_cm_to_height_feet)/height_cm_to_height_inches;
printf("%.1lf cm = %d feet, %.1lf inches\n",height_cm,height_feet,height_inches);
printf("Enter a height in centimeters (<=0 to quit):\n");
scanf("%lf",&height_cm);
}
printf("bye");
}
//第五题
#include<stdio.h>
int main()
{
int cnt, sum, n;
sum=0;
cnt=0;
printf("How many days dou you want to work?\n");
scanf("%d",&n);
while(cnt++<n)
{
sum=sum+cnt;
}
printf("sum=%d\n",sum);
}
//第六题
#include<stdio.h>
int main()
{
int cnt, sum, n;
sum=0;
cnt=0;
printf("How many days dou you want to work?\n");
scanf("%d",&n);
while(cnt++<n)
{
sum=sum+cnt*cnt;
}
printf("sum=%d\n",sum);
}
//第七题
#include<stdio.h>
void cube(double number);
int main()
{
printf("Please enter a number in double:\n");
double number;
scanf("%lf",&number);
cube(number);
}
void cube(double number)
{
printf("The cube of this number is %lf",number*number*number);
}
//第八题
#include<stdio.h>
int main()
{
int second_operand;
int first_operand;
printf("This program computes moduli.\n");
printf("Enter an integer to serve as the second operand: ");
scanf("%d",&second_operand);
printf("Now enter the first operand: ");
scanf("%d",&first_operand);
while(first_operand>0){
printf("%d %% %d is %d",first_operand,second_operand,first_operand%second_operand);
printf("\nEnter next number for first operand (<= 0 to quit): ");
scanf("%d",&first_operand);
}
printf("Done!");
}
//第九题
#include<stdio.h>
void Temperaturs(double temperatur);
int main()
{
printf("Plesae enter a Fahrenheit temperatur:\n");
double temperatur;
while(scanf("%lf",&temperatur)==1){
Temperaturs(temperatur);
printf("Plesae enter another Fahrenheit temperatur(q to quit):\n");
}
printf("Done!");
}
void Temperaturs(double temperatur)
{
const double Fahrenheit_decrease=32.0;
const double Kelvin_increase=273.16;
const double centigrade=5.0/9.0*(temperatur-Fahrenheit_decrease);
const double Kelvin=centigrade+Kelvin_increase;
printf("Fahrenheit:%.2lf centigrade: %.2lf Kelvin:%.2lf\n",temperatur,centigrade,Kelvin);
}