| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 460 人关注过本帖
标题:请问如何限制n的次数为5?
取消只看楼主 加入收藏
wu47589791
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2009-10-12
结帖率:66.67%
收藏
已结贴  问题点数:9 回复次数:0 
请问如何限制n的次数为5?
#include <stdio.h>

void main() {
int c,n;
double num1,result;
char option;
/*printf("The number of conversions to be performed");*/
scanf("%d",&n);

for(c=1;c<=n;c++){
       /*printf("%d",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;
  }
}

}
请问如何限制n的次数为5?
也就是最多能转换5次。谢谢
搜索更多相关主题的帖子: equivalent performed include double 
2009-10-19 12:21
快速回复:请问如何限制n的次数为5?
数据加载中...
 
   



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

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