[求助]数据输入判断问题!
#include "stdafx.h"double p=3.1415926,r1,r2,h,t;
double vv(double r1,double r2,double h);
void main()
{
char a,b,c;
int r11,r22,hh;
k:
printf("请输入内径:");
scanf("%c",&a);
r11=a-'0';
printf("请输入外径:");
scanf("%c",&b);
r22=b-'0';
if(r22<r11 || r11<='0'||r22<='0'||r11>='9'||r22>='9')
//if里面的是想判断,如果输入的不是数字而是其他字符就提示输入错误
//或者是输入“内径”大于“外径”的时候也报错!
{
printf("数据输入错误\n");
goto k;
}
else
printf("请输入高:");
scanf("%c",&c);
hh=c-'0';
t=vv(r2,r1,h);
printf("体积为:%lf\n",t);
}
double vv(double r2,double r1,double h)
{
t=p*(r2*r2-r1*r1)*h;
return t;
}