//第 1 题
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define MIN_PER_HOU 60
int main(int argc, char* argv[])
{
int hours, minutes, input;
printf("CONVERT MINUTES TO HOURS!\n");
printf("PLEASE INPUT THE NUBER OF MINUTES( <=0 TO QUIT ):");
scanf("%d", &input);
while (input > 0)
{
hours = input / MIN_PER_HOU;
minutes = input % MIN_PER_HOU;
printf("CONVERT TO %d HOUR AND %d MINUTES\n", hours, minutes);
printf("PLEASE CONTINUE INPUT THE NUMBER OF MINUTES( <=0 TO QUIT ):");
scanf("%d", &input);
}
printf("PROGRAM EXIT!\n");
}
//第 2 题
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(int argc, char* argv[])
{
int counter, i = 0;
printf("PRINT COUNTINUE 10 NUMBERS!\n");
printf("PLEASE INPUT THE START NUMBER :");
scanf("%d", &counter);
while (i++ < 11)
{
printf(" %d \n", counter++);
}
printf("PROGRAM EXIT!\n");
return 0;
}
//第 3 题
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define WEEK_PER_DAY 7
int main(int argc, char* argv[])
{
int days, weeks, input;
printf("CONVERT DAYS 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 % WEEK_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;
}
//第 4 题
#define _CRT_SECURE_NO_WARNINGS
#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;
}
//第 5 题
#define _CRT_SECURE_NO_WARNINGS
#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 > 0)
{
sum = sum + count--;
}
printf("You earned $ %d total!\n", sum);
printf("PROGRAM EXIT!\n");
return 0;
}
//第 6 题
#define _CRT_SECURE_NO_WARNINGS
#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 > 0)
{
sum = sum + count * count;
count--;
}
printf("You earned $ %d total!\n", sum);
printf("PROGRAM EXIT! \n");
return 0;
}
//第 7 题
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
double cubic(double n);
int main(int argc, char* argv[])
{
double input;
printf("Enter the double datum to calc cubic :");
scanf("%lf", &input);
cubic(input);
printf("PROGRAM EXIT!\n");
return 0;
}
double cubic(double n)
{
double t = n * n * n;
printf("The %lg's cubic is %lg !\n", n, t);;
return t;
}
//第 8 题
#define _CRT_SECURE_NO_WARNINGS
#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;
}