第一题
#include<stdio.h> const int TIME = 60; int main(void) { int mins; printf("PLease Input The Time(MIN):"); scanf("%d",&mins); while(mins > 0) { printf("Now It's %d Hours And %d Mins.\n",mins/TIME,mins%TIME); printf("PLease Input The Time(MIN):"); scanf("%d",&mins); } printf("Done!\n"); return 0; }
第二题
#include<stdio.h> const int LEVEL = 10; int main(void) { int BeginNumber; int EndNumber; printf("Please Input The Any Number:"); scanf("%d",&BeginNumber); EndNumber = BeginNumber + LEVEL; while(BeginNumber <= EndNumber) { printf("%d ",BeginNumber); ++BeginNumber; } return 0; }
第三题
#include<stdio.h> const int WD = 7; int main(void) { int Days; printf("Please Input The Days:"); scanf("%d",&Days); while(Days > 0) { printf("%d days are %d weeks , %d days\n", Days , Days/WD ,Days%WD); printf("Please Input The Days:"); scanf("%d",&Days); } return 0; }
第四题
#include<stdio.h> const double CF = 25.4; const double FI = 12; //我对英制单位不了解,我是按 1 inch = 12 feet , 1 feet = 25.4cm的关系来换算的 int main(void) { double CMs; double FEETs; printf("PLease Input Any Hight By Cm:"); scanf("%lf",&CMs); while(CMs > 0) { FEETs = CMs / CF; printf("%.1lf cm = %.0lf feet , %.1lf inchs.\n", CMs , FEETs , FEETs/FI); printf("PLease Input Any Hight By Cm:"); scanf("%lf",&CMs); } printf("Done!\n"); return 0; }
第五题
#include<stdio.h> const int LIMIT = 20; int main(void) { int BeginNumber; int EndNumber; int Sums = 0; printf("PLease Input Any Number:"); scanf("%d",&BeginNumber); EndNumber = BeginNumber + LIMIT; while(BeginNumber < EndNumber) { Sums += BeginNumber; ++BeginNumber; } printf("The Sum is %d.\n",Sums); }
第六题
#include<stdio.h> const int LIMIT = 20; int main(void) { int BeginNumber; int EndNumber; int Sums = 0; printf("PLease Input Any Number:"); scanf("%d",&BeginNumber); EndNumber = BeginNumber + LIMIT; while(BeginNumber < EndNumber) { Sums = Sums + BeginNumber*BeginNumber; ++BeginNumber; } printf("The Sum is %d.\n",Sums); }
第七题
#include<stdio.h> void PrintFloat(float fl); int main(void) { float TestNu; printf("PLease Input A Number To Test:"); scanf("%f",&TestNu); PrintFloat(TestNu); return 0; } void PrintFloat(float fl) { printf("%f\n",fl*fl*fl); }
第八题
#include<stdio.h> const double FC_1 = 1.8; const double FC_2 = 32.0; const double CK = 273.16; void Temperatures(double Fah); int main(void) { double TemperatureF; printf("Please Input The Temparetures(F):"); while((scanf("%lf",&TemperatureF) == 1)) { Temperatures(TemperatureF); printf("Please Input The Temparetures(F):"); } printf("Done!\n"); return 0; } void Temperatures(double Fah) { double Cel = FC_1 * Fah + FC_2; double Kel = Cel + CK; printf("%.2lf F = %.2lf C = %.2lf K\n",Fah,Cel,Kel); }