用指向数组的指针作为函数参数(2)

练习03-17-03

从三个学生四门成绩的二维数组中,寻找到有成绩不及格的学生,输出对应成绩:

输出样例:

The original score matrix:
  75.00  31.00  44.00  21.00
  12.00  82.00  37.00  48.00
  51.00  99.00   7.00  32.00
The list of failed student:
The score of NO1:  75.00  31.00  44.00  21.00
The score of NO2:  12.00  82.00  37.00  48.00
The score of NO3:  51.00  99.00   7.00  32.00

--------------------------------
Process exited after 0.054 seconds with return value 0
请按任意键继续. . .

代码如下:

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
	srand((unsigned)time(NULL));
	float score[3][4];
	int i,j;
	printf("The original score matrix:\n");
	for(i=0;i<3;i++){
		for(j=0;j<4;++j){
			score[i][j]=rand()%100;
			printf("%7.2f",score[i][j]);
		}putchar('\n');
	}
	printf("The list of failed student:\n");
	void find_fail(float (*p)[4],int n);
	find_fail(score,3);
	return 0;
}
void find_fail(float (*p)[4],int n)
{
	int i,j,flag=0;
	void search(float (*p)[4],int n);
	for(i=0;i<3;++i){
		int count=0;
		for(j=0;j<4;++j){
			if(*(*(p+i)+j)<60)	++count;
		}
		if(count>0){
			search(p+i,i);
		}
	}
}
void search(float (*p)[4],int n)
{
	printf("The score of NO%d:",n+1);
	int i;
	for(i=0;i<4;++i){
		printf("%7.2f",*(*p+i));
	}
	putchar('\n');
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值