指针 练习
2016-10-04 19:50
106 查看
//3个学生,4门科目,计算总均分及输出第i位同学成绩
#include <stdio.h>
int main()
{
int average(float* p,int n);
int search(float(*p)[4],int n);
float score[3][4]={{65,67,70,60},{80,87,90,81},{90,99,100,98}};
average(*score,12);
search(score,2);
return 0;
}
int average(float *p,int n)
{
float *p_end;
float sum=0,aver;
p_end=p+n-1;
for(;p<=p_end;p++)
sum=sum+(*p);
aver=sum/n;
printf("average=%5.2f\n",aver);
return 0;
}
int search(float(*p)[4],int n)
{
int i;
printf("the score of No.%d are:\n",n);
for(i=0;i<4;i++)
printf("%5.2f",*(*(p+n)+i));
printf("\n");
return 0;
}
#include <stdio.h>
int main()
{
int average(float* p,int n);
int search(float(*p)[4],int n);
float score[3][4]={{65,67,70,60},{80,87,90,81},{90,99,100,98}};
average(*score,12);
search(score,2);
return 0;
}
int average(float *p,int n)
{
float *p_end;
float sum=0,aver;
p_end=p+n-1;
for(;p<=p_end;p++)
sum=sum+(*p);
aver=sum/n;
printf("average=%5.2f\n",aver);
return 0;
}
int search(float(*p)[4],int n)
{
int i;
printf("the score of No.%d are:\n",n);
for(i=0;i<4;i++)
printf("%5.2f",*(*(p+n)+i));
printf("\n");
return 0;
}
相关文章推荐
- 第9周 指针练习:MyMax
- 指针综合练习
- C和指针第二章编程练习
- 指针第一次练习
- EOJ 3018 查找单词【指针练习】
- C语言函数指针练习
- Boost练习3——内存管理之智能指针
- C++文本查询程序 定义类管理数据 用引用共享数据 不用智能指针 C++Primer练习12.27
- C++文本查询程序 定义类管理数据 用智能指针 C++Primer练习12.30
- C++文本查询程序 定义类管理数据 用智能指针 用StrBlob代替vector<string> C++Primer 练习12.32
- C语言练习篇-7数组与指针、指针加减练习
- (指针练习)GetMemory错误讲解
- 最简单的指针与地址练习(二维数组)0
- C++文本查询程序 定义类管理数据 用智能指针 C++Primer练习12.30
- C++文本查询程序 定义类管理数据 用引用共享数据 不用智能指针 C++Primer练习12.27
- C 语言编程练习,实践,解决方案:指针
- 3第一周课后练习·阅读计划(2)-使用指针来访问私有数据成员
- C语言指针练习之不等长字符排序
- C和指针 练习 1-3
- 指针练习