#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
//公顷hm²,亩Mu,平方米m²,平方厘米cm²
void AreaMenu() {
printf("****************************************\n");
printf("*\t\t1.公顷转化\t\t*\n");
printf("*\t\t2.亩转化 \t\t*\n");
printf("*\t\t3.平方米转化 \t\t*\n");
printf("*\t\t4.平方厘米转化 \t\t*\n");
printf("*****************************************\n");
}
int main()
{
AreaMenu();
double m,n;
char hm2,Mu,m2,cm2;
char a[4];
int i;
printf("请输入要算的数:");
scanf("%lf",&m);
printf("请输入您的选择:");
scanf("%lf",&i);
switch(i)
{
case 1://hm²
printf("输入您想要转化成的单位: ");
scanf("%s",&a);
if(strcmp(a,"hm2")==0) n=m;
else if(strcmp(a,"Mu")==0) n=m*0.067;
else if(strcmp(a,"m2")==0) n=m*0.0001;
else if(strcmp(a,"cm2")==0) n=m*0.00000001;
printf("%lf in=%lf %s",m,n,a);
break;
case 2://Mu
printf("输入您想要转化成的单位: ");
scanf("%s",&a);
if(strcmp(a,"hm2")==0) n=m*15;
else if(strcmp(a,"Mu")==0) n=m;
else if(strcmp(a,"m2")==0) n=m*0.0015;
else if(strcmp(a,"cm2")==0) n=m*0.00000015;
printf("%lf in=%lf %s",m,n,a);
break;
case 3://m²
printf("输入您想要转化成的单位: ");
scanf("%s",&a);
if(strcmp(a,"hm2")==0) n=m*10000;
else if(strcmp(a,"Mu")==0) n=m*666.67;
else if(strcmp(a,"m2")==0) n=m;
else if(strcmp(a,"cm2")==0) n=m*0.0001;
printf("%lf in=%lf %s",m,n,a);
break;
case 4://cm²
printf("输入您想要转化成的单位: ");
scanf("%s",&a);
if(strcmp(a,"hm2")==0) n=m*100000000;
else if(strcmp(a,"Mu")==0) n=m*6670000;
else if(strcmp(a,"m2")==0) n=m*10000;
else if(strcmp(a,"cm2")==0) n=m;
printf("%lf in=%lf %s",m,n,a);
break;
default:
printf("输入错误请重新输入");
}
return 0;
}