标题:如何修改才能print出列表型?
只看楼主
wu47589791
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2009-10-12
结帖率:66.67%
 问题点数:0 回复次数:1 
如何修改才能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
搜索更多相关主题的帖子: 列表 print 
2009-10-20 23:39
jiangwu10057
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:341
专家分:667
注 册:2009-3-25
得分:0 
这个不知道是什么
不过我知道要想换类型可以使用
强制转换
不知道能不能帮到你
(float)a;     强制转换
1     2000.00 0.30  609.60
4     79.50   4.55  361.41(float)
错了  就别见怪
我练你写的什么都不知道
switch还没学
2009-10-21 12:15



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-289306-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.925603 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved