#include<stdio.h>
int Judge(int);//判断用户输入的是否为整数
int main()
{
int longs;//长方形的长
int weight;//长方形的宽
int s = 0;//长方形的面积
printf("请输入长方形的长和宽:");
do{
scanf("%d %d",&longs,&weight);
if(!Judge(longs) || !Judge(weight))
{
printf("请输入正整数:");
}
}while(!Judge(longs) || !Judge(weight));
s = longs * weight;
printf("长方形的面积为:%d",s);
}
int Judge(int a)
{
return a > 0;
}
正方形面积的计算和判断用户的输入
最新推荐文章于 2021-09-12 13:49:15 发布