| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 349 人关注过本帖
标题:求 循环运行这个程序
只看楼主 加入收藏
lystar930304
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-1-2
结帖率:0
收藏
 问题点数:0 回复次数:1 
求 循环运行这个程序
#include <stdio.h>
#include <math.h>
void main ( )
{
    int a,b,c,d,e,f;
    double u1,u2;
    printf("1.Pa\n");
    printf("2.kPa\n");
    printf("3.MPa\n");
    printf("4.bar\n");
    printf("5.Torr\n");
    printf("please choose the unit:");
    scanf("%d",&a);
    printf("please enter the value:");
    scanf("%lf",&u1);
    switch (a)
    {
    case 1:
        printf("1.kPa\n");
        printf("2.MPa\n");
        printf("3.bar\n");
        printf("4.Torr\n");
        printf("please choose the unit which you want to convert:");
        scanf("%d",&b);
        if (b==1)
        {
            u2=u1/1000;
            printf("%lf Pa=%lf kPa\n",u1,u2);
        }
        else if (b==2)
        {
            u2=u1/1000000;
            printf("%lf Pa=%lf MPa\n",u1,u2);
        }
        else if (b==3)
        {
            u2=u1/100000;
            printf("%lf Pa=%lf bar\n",u1,u2);
        }
        else if (b==4)
        {
            u2=u1/0.00750063755419211;
            printf("%lf Pa=%lf Torr\n",u1,u2);
        }
        else
            printf("error!\n");
        break;
    case 2:
        printf("1.Pa\n");
        printf("2.MPa\n");
        printf("3.bar\n");
        printf("4.Torr\n");
        printf("please choose the unit which you want to convert:");
        scanf("%d",&c);
        if (c==1)
        {
            u2=u1*1000;
            printf("%lf kPa=%lf Pa\n",u1,u2);
        }
        else if (c==2)
        {
            u2=u1*0.001;
            printf("%lf kPa=%lf Mpa\n",u1,u2);
        }
        else if (c==3)
        {
            u2=u1*0.01;
            printf("%lf kPa=%lf bar\n",u1,u2);
        }
        else if (c==4)
        {
            u2=u1*7.50063755419211;
            printf("%lf kPa=%lf Torr\n",u1,u2);
        }
        else
            printf("error!\n");
        break;
    case 3:
        printf("1.Pa\n");
        printf("2.kPa\n");
        printf("3.bar\n");
        printf("4.Torr\n");
        printf("please choose the unit which you want to convert:");
        scanf("%d",&d);
        if (d==1)
        {
            u2=u1*1000000;
            printf("%lf MPa=%lf Pa\n",u1,u2);
        }
        else if (d==2)
        {
            u2=u1*1000;
            printf("%lf MPa=%lf kPa\n",u1,u2);
        }
        else if (d==3)
        {
            u2=u1*10;
            printf("%lf MPa=%lf bar\n",u1,u2);
        }
        else if (d==4)
        {
            u2=u1*7500.63755419211;
            printf("%lf MPa=%lf Torr\n",u1,u2);
        }
        else
            printf("error!\n");
        break;
    case 4:
        printf("1.Pa\n");
        printf("2.kPa\n");
        printf("3.MPa\n");
        printf("4.Torr\n");
        printf("please choose the unit which you want to convert:");
        scanf("%d",&e);
        if (e==1)
        {
            u2=u1*100000;
            printf("%lf bar=%lf Pa\n",u1,u2);
        }
        else if (e==2)
        {
            u2=u1*100;
            printf("%lf bar=%lf kPa\n",u1,u2);
        }
        else if (e==3)
        {
            u2=u1*0.1;
            printf("%lf bar=%lf MPa\n",u1,u2);
        }
        else if (e==4)
        {
            u2=u1*750.063755419211;
            printf("%lf bar=%lf Torr\n",u1,u2);
        }
        else
            printf("error!\n");
        break;
    case 5:
        printf("1.Pa\n");
        printf("2.kPa\n");
        printf("3.MPa\n");
        printf("4.bar\n");
        printf("please choose the unit which you want to convert:");
        scanf("%d",&f);
        if (f==1)
        {
            u2=u1*133.322;
            printf("%lf Torr=%lf Pa",u2);
        }
        else if (f==2)
        {
            u2=u1*0.133322;
            printf("%lf Torr=%lf kPa\n",u1,u2);
        }
        else if (f==3)
        {
            u2=u1*0.000133322;
            printf("%lf Torr=%lf MPa\n",u1,u2);
        }
        else if (f==4)
        {
            u2=u1*0.00133322;
            printf("%lf Torr=%lf bar\n",u1,u2);
        }
        else
            printf("error!\n");
        break;
    default:
        printf("error!");
        break;
    }
    system("pause");
}





哪位大侠帮帮忙 可以让这个程序循环运行 算出结果以后可以回到第一步 在这小弟先谢过了
搜索更多相关主题的帖子: void include please double 
2013-01-28 19:27
心灯甚亮
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:2
帖 子:441
专家分:996
注 册:2013-1-29
收藏
得分:0 
不介意的话用goto吧
2013-01-29 15:10
快速回复:求 循环运行这个程序
数据加载中...
 
   



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

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