如何修改才能print出列表型?
功课来的,想了很久 投降了。。。高手看看#include <stdio.h>
void main() {
int c,n;
double num1,result;
char option;
/*printf("The number of conversions to be performed");*/
scanf("%d",&n);
if(n<=5){
for(c=1;c<=n;c++){
scanf(" %c",&option);
scanf(" %lf",&num1);
switch (option) {
case '1':result=num1*0.3048;
printf("\n%.2lf feet equivalent to %.2lf meters\n",num1,result);
break;
case '2':result=num1*1.852;
printf("%.2lf nautical miles equivalent to %.2lf kilometers\n",num1,result);
break;
case '3':result=num1*0.016387;
printf("%.2lf cubic equivalent to %.2lf liters\n",num1,result);
break;
case '4':result=num1*4.54609;
printf("%.2lf gallons equivalent to %.2lf liters\n",num1,result);
break;
case '5':result=num1*4046.8564;
printf("%.2lf acers equivalent to %.2lf square meters\n",num1,result);
break;
case '6':result=num1*0.4535924;
printf("%.2lf pounds equivalent to %.2lf kilograms\n",num1,result);
break;
case '7':result=num1*1016.0469;
printf("%.2lf tons equivalent to %.2lf kilograms\n",num1,result);
break;
case '8':result=num1*745.7;
printf("%.2lf horsepower equivalent to %.2lf watts",num1,result);
break;
case '9':result=num1*1.01387;
printf("%.2lf horsepower equivalent to %.2lf metric horsepower",num1,result);
break;
}
printf("Code\tAmount\tRatio\tConverted Amount\n");
printf("----\t------\t-----\t----------------\n");
printf("%d ",option);
}
}
}
要求最终的格式如下图 最多可以转化5次
2
1 2000
4 79.5
Code Amount Ratio Converted Amount
---- ------ ----- ----------------
1 2000.00 0.30 609.60
4 79.50 4.55 361.41