这里的难点是求余数,并不是简单的求于运算,如果总成绩不能被三整除余数应该是一个小数,而求于运算只能对两个整数进行运算,在这里因该注意。
#include
main()
{
int i,a[3],sum=0;
double rem,ave;
printf("please input the course of three sdepts:\n");
for(i=0;i<3;i++)
scanf("%d",&a[i]);
for(i=0;i<3;i++)
sum+=a[i];
ave=sum/3;
rem=ave-(int)(ave);
printf("the total of the course is:%d\n average is :%f\n rem is :%f\n",sum,ave,rem);
}
#include
void main()
{
float l1,l2,l3,sum,ave,rem;
cout<<"请输入第一门课的成绩:";
cin>>l1;
cout<
cin>>l2;
cout<
cin>>l3;
cout<
ave=sum/3;
rem=(int)sum%3+sum-(int)sum;
cout<<"3们成绩的和为:"<
#include
main()
{
int a[3],sum=0,rem,i;
double avg;
printf("Input 3 scores:\n");
for(i=0;i<3;i++)
{scanf("%d",&a[i]);sum+=a[i];}
avg=sum/3.0;
rem=sum%3;
}
//验证成功