第一题
#include <stdio.h>
#include<string>)
int main(void)
{
int a;
printf("Entger a number:");
scanf_s("%d", &a);
if (a < 10)
printf("The number %d has 1 digtis\n",a);
else if(a<100)
printf("The number %d has 2 digtis\n", a);
else if (a<1000)
printf("The number %d has 3 digtis\n", a);
else
printf("The number %d has 4 digtis\n", a);
system("pause");
return 0;
}
第二题
#include <stdio.h>
#include<string>)
int main(void)
{
int a,b;
printf("Enter a 24-hour time:");
scanf_s("%d:%d", &a, &b);
if (a < 13)
printf("Equivalent 12-hour time: %d:%d AM", a, b);
else
printf("Equivalent 12-hour time: %d:%d PM", a % 12, b);
system("pause");
return 0;
}
第三题
#include <stdio.h>
#include<string>)
int main(void)
{
float commission, value,number,price, commissionA;
printf("Enter number of trade: ");
scanf_s("%f", &number);
printf("Enter price of trade: ");
scanf_s("%f", &price);
value = price * number;
if (number < 2000.00f)
commissionA = (number * 33 + 3) / 100;
else
commissionA = (number * 33 + 2) / 100;
if (value < 2500.f)
commission = 30.00f + .017f * value;
else if (value < 6250.00f)
commission = 56.00f + .0066f * value;
else if (value < 20000.00f)
commission = 76.00f + .0034f * value;
else if (value < 50000.0