标签:student sys 语言 i++ style print std float use
1.
#include<stdlib.h>
#include<stdio.h>
void main(){
char students[ ]{67,78,89,43,92,100 };
int length=sizeof (students)/sizeof(char); //数组长度公式
int l_sum=0;
float l_average=0;
for(size_t i=0; i<lenght:i++)
{
l_sum=l_sum+students[i];
}
l-average=l_sum/lenght;
printf("总成绩=%d分\n 平均分:%.1f\n",l_sum,l_average);
system("pause");
}
2.
#include<stdio.h>
#include<stdlib.h>
void main(){
int l_a=67;
int l_b=78;
int l_c=89
int l_d=43;
int l_e=92;
float l_sum=l_a+l_b+l_c+l_d+l_e;
float l_average=l_sum/5;
printf("总成绩=%d分\n 平均分:%.1f\n",l_sum,l_average);
system("pause");
}
标签:student sys 语言 i++ style print std float use
原文地址:http://www.cnblogs.com/lenaben/p/7123535.html