#include
int main()
{
int a, b, c;
int res = 3;
printf("请输入身高、收入、魅力值:");
scanf("%d %d %d", &a, &b, &c);
if(a < 160 && b < 2000 && c < 60)
res = 1;
else if(a > 170 && b > 18000 && c >= 80)
res = 2;
else
res = 0;
if(getchar() != '\n') {
res = 3;
}
switch(res){
case 1:
printf("low-uglily-poor\n");
break;
case 2:
printf("tall-rich-handsome\n");
break;
default:
printf("unknow\n");
}
return 0;
}
结果:
bash-4.1$ ./a.out
请输入身高、收入、魅力值:1 2 3
low-uglily-poor
bash-4.1$ ./a.out
请输入身高、收入、魅力值:1 2 3 4
unknow
#include
int main(){
int height=178;
int salary=1800;
int handsome=100;
printf("请输入身高、收入、魅力值:\n");
scanf("%d %d %d",&height,&salary,&handsome);
if(height<160 && salary <2000 && handsome <6)printf("ow-uglily-poor\n");
else if(height>170 && salary>18000 && handsome>=80) printf("\n");
else printf("unknown\n");
return 0;
}
#include
int main(){
int a, b, c;
int res = 3;
printf("请输入 身高 收入 魅力值;");
scanf("%d %d %d", &a, &b, &c);
if(a < 160 && b < 2000 && c < 60)
res = 1;
else if(a > 170 && b > 18000 && c >= 80)
res = 2;
else
res = 0;
switch(res){
case 1:
printf("low-uglily-poor");
break;
case 2:
printf("tall-rich-handsome");
break;
default:
printf("unknow");
}
return 0;
}
#include
void main(){
int length,money,value;
char rst;
printf("请输入身高、收入、魅力值:");
scanf("%d %d %d",&length,&money,&value);
if(length<160&&money<2000&&value<60){
rst = 'a';
}else if(length>170&&money>18000&&value>=80){
rst = 'b';
}else{
rst = 'c';
}
switch(rst){
case 'a':printf("low-uglily-poor");break;
case 'b':printf("tall-rich-handsome");break;
default:printf("unknow");break;
}
getchar();
getchar();
}
void main()
{
int a;//身高
long b,c;//收入 魅力值
int i;//判断类型
printf("请输入身高:");
scanf("%d",&a);
printf("\n输入收入:");
scanf("%d",&b);
printf("\n魅力值:");
scanf("%d",&c);
if(a<160&&b<2000&&c<60)
i=1;
else if(a>170&& b>18000&&c>=80)
i=2;
else
i=3;
switch(i)
{
case 1:
printf("low-uglily-poor");
break;
case 2:
printf("tall-rich-handsome");
break;
case 3:
printf("unknow");
break;
defult:
printf("unknow");
break;
}
}