#include<stdio.h>
#include<math.h>
float Y,D,E;
void Y_to_D(float x)
{
D = 0.141 * x;
printf("%f",D);
}
void Y_to_E(float x)
{
E = 0.127 * x;
printf("%f",E);
}
void E_to_Y(float x)
{
Y = 7.869 * x;
printf("%f",Y);
}
void E_to_D(float x)
{
D = 1.113 * x;
printf("%f",D);
}
void D_to_E(float x)
{
E = 1.113 * x;
printf("%f",E);
}
void D_to_Y(float x)
{
Y = 7.070 * x;
printf("%f",Y);
}
int main()
{
float a;
char choice;
printf("1-RMB is converted into dollars\n");
printf("2-RMB is converted into euros\n");
printf("3-The dollar is converted into euros\n");
printf("4-The dollar is converted into RMB\n");
printf("5-Euros are converted into dollars\n");
printf("6-Euros are converted into RMB\n");
printf("please input your choice :");
scanf("%c",&choice);
printf("Please enter your amount :");
scanf("%f",&a);
switch(choice)
{
case 1 :
Y_to_D(a);
break;
case 2 :
Y_to_E(a);
break;
case 3 :
D_to_E(a);
break;
case 4 :
D_to_Y(a);
break;
case 5 :
E_to_D(a);
break;
case 6 :
E_to_Y(a);
break;
}
return 0;
}
int choice;
scanf("%d", &choice);
或者
case '1':
case '2':
......