图片貌似不清楚,还是发代码吧
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char choice1=0,choice2=0;
int num=0,total=0,count=0;
printf("您好,这是一个求平均值的程序请问是否决定运行(y/n):");
scanf("%c",&choice1);
if(choice1==*y*)
{
for(count=1;;++count)
{
printf("您输入您的第%d个数据:",count);
scanf("%d",&num);
total += num;
printf("请问还要继续输入么(y/n):");
scanf("%d",&choice2);
if(choice2==*n*)
break;
}
}
else if(choice1==*n*)
{
printf("您取消了程序的运行,本程序结束\n");
goto there;
}
else
printf("您共输入了%d个数字,和是%d,平均值是%lf\n\n",count,total,total/count);
there:
system("pause");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char choice1=0,choice2=0;
int num=0,total=0,count=0;
printf("您好,这是一个求平均值的程序请问是否决定运行(y/n):");
scanf("%c",&choice1);
if(choice1==*y*)
{
for(count=1;;++count)
{
printf("您输入您的第%d个数据:",count);
scanf("%d",&num);
total += num;
printf("请问还要继续输入么(y/n):");
scanf("%d",&choice2);
if(choice2==*n*)
break;
}
}
else if(choice1==*n*)
{
printf("您取消了程序的运行,本程序结束\n");
goto there;
}
else
printf("您共输入了%d个数字,和是%d,平均值是%lf\n\n",count,total,total/count);
there:
system("pause");
return 0;
}