|
5啊哈币
- #include<stdio.h>
- void main()
- {int menu()
- {double ElecCost(double x);
- double WaterCost(double x);
- double GasCost(double x);
- printf("欢迎使用居民缴费系统");
- menu()
- }
- double ElecCost (double x);
- {double y;
- if (x>=0&&x<=30);
- y=0.8x;
- if (x>30);
- y=0.5x;
- printf("%f",y);
- }
- void
- menu ()
- double WaterCost(double x);
- {double y;
- if(X>=0&&x<=15);
- y=4*x/3;
- if (x>15);
- y=2.5*x-10.5;
- printf("%f",y);
- }
- void
- menu()
- void
- {
- int n;
- double x;
- printf ("请输入数字1——3选择某个数");
- printf ("1.电费缴费系统");
- printf ("2.水费缴费系统");
- printf ("3.燃气费缴费系统");
- scanf ("%d ",&n);
- switch(n)
- {
- case 1:
- printf("请输入居民当月所用电量");
- scanf("%f",&x);
- ElecCost(x);
- }
- break;
- case 2;
- {
- printf("请输入居民当月所用水量");
- scanf ("%f",&x);
- WaterCost(x);
- }
- break;
- case 3;
- {
- printf("请输入居民当月所用燃气量");
- scanf("%f",&x);
- GasCost(x);
- break;
- }
- }
复制代码 |
|