Home > Back-end >  The C language
The C language

Time:01-25

I want to return pointer function is used to judge the mo some classmates failed the individual subject, and to output their student number, grade, but I don't this always lose out as a result, hope bosses to give directions, thank you



# include "stdio.h"
Int main ()
{
Float grade [] [4]=60,70,80,90,56,89,67,88,34,78,90,66 {};//store performance
Float * search (float (* pointer) [4]);
Float * p;
int i,j;
for(i=0; i<3; I++)
{
P=search (grade a + I);
If (p==* (grade a + I))
Printf (" No. % d ", I);//output student id
for(j=0; j<4. J++)
Printf (" % 5.2 f ", * (p + j));//output meet the conditions of student achievement
printf("\n");
}
}
Float * search (float (* pointer) [4])
{
Float * pt;
int i=0;
Pt=NULL;
for(; i<4. I++)
If (* (* pointer + I) & lt; 60) pt=* pointer;
Return pt;
}

CodePudding user response:

Reference:
 # include "stdio.h" 

Int main (int arg c, char * argv [])
{
Float grade [] [4]=60,70,80,90,56,89,67,88,34,78,90,66 {};//store performance
Float * search (float (* pointer) [4]);
Float * p;
int i,j;
for(i=0; i<3; I++)
{
P=search (grade a + I);
If (p) {//if (p==* (grade a + I)) {
Printf (" No. % d ", I + 1);//output student id
for(j=0; j<4. J++)
Printf (" % 6.2 f ", * (* (grade a + I) + j));//output meet the conditions of student achievement
printf("\n");
}
}

//system (" pause ");
return 0;
}


Float * search (float (* pointer) [4])
{
Float * pt;
int i;
Pt=NULL;
for(i=0; i<4. I++)
If (* (* pointer + I) & lt; 60) pt=(* pointer + I);
Return pt;
}

CodePudding user response:

The method of the building Lord:
 # include "stdio.h" 
Int main ()
{
Float grade [] [4]=60,70,80,90,56,89,67,88,34,78,90,66 {};//store performance
Float * search (float (* pointer) [4]);
Float * p;
int i,j;
for(i=0; i<3; I++)
{
P=search (grade a + I);
If (p==* (grade a + I)) {
Printf (" No. % d ", I + 1);//output student id
for(j=0; j<4. J++)
Printf (" % 6.2 f ", * (p + j));//output meet the conditions of student achievement
printf("\n");
}
}

//system (" pause ");
return 0;
}


Float * search (float (* pointer) [4])
{
Float * pt;
int i;
Pt=NULL;
for(i=0; i<4. I++)
If (* (* pointer + I) & lt; 60) pt=* pointer;
Return pt;
}
  • Related