回复 楼主 fclzss
死循环语句#include<stdio.h>
float average_number(float a,float b);
int main(void)
{
float num1,num2;
int a,b;
printf("this program caculate average.\n");
printf("now please enter first num:");
a=scanf("%f",&num1);
while(a!=1)
{
printf("please enter a float number:");
a=scanf("%f",&num1);
}
printf("now enter second number:");
b=scanf("%f",&num2);
while(b!=1)
{
printf("please enter a float number:");
b=scanf("%f",&num2);
}
printf("%f\n", average_number( num1, num2));
printf("bye\n");
return 0;
}
float average_number(float a,float b)
{
float aver;
a=1/a;
b=1/b;
aver=a+b;
aver=1/aver;
return aver;
}