27. There is an integer two-dimensional array of size m x n, which asks for the row and column where the maximum value is located and the maximum value. Write a function max, which requires the following://(1) with the array name and the size of the function parameter//(2) The value of the array element is entered in the main function, the result is output /* in function Max #include <stdio.h>int max (int x[3][4],int m,int n) {int max=x[0][0];int i,j;for (i=0;i<m;i++) for (j=1 ; j<n;j++) if (Max<x[i][j]) max=x[i][j];for (i=0;i<m;i++) for (j=0;j<n;j++) if (X[i][j]==max) printf (" The maximum value is in line%d, which is listed in column%d \ n ", i,j); Return max;} Int main () {int a[3][4],i,j,k;printf ("Enter the value of the element in the array:"), for (i=0;i<3;i++) for (j=0;j<4;j++) scanf ("%d", &A[I][J]); K=max (a,3,4);p rintf ("max is %d\n", k); return 0;} */#include <stdio.h>void maxval (int arr[][4],int m,int n) { int i,j,max,line =0,col=0; int (*p) [4]; max=arr[0][0]; p=arr; for (i=0;i<m;i++) for (j=0;j<n;j++) if (max<* (* (p+i) +j)) { max=* (* (p+i) +j); line=i; col=j; }}int main () { int array[3][4],i,j,k,c; printf ("Input lines&nbSp;of array: "); &NBSP;SCANF ("%d ", &k); printf (" \ninput column of array: "); scanf ("%d", &c); printf ("\ninput data use comma between data \n"); for (i=0;i<k;i++) for (j=0;j<c;j++) printf ("%4d", Array[i][j]); printf ("\ n"); Maxval (Array,k, c); return 0;}
28. There are n students, each of whom take the M-course exam, and ask to write a function that can check that n students have passed the course. If a student does not pass one or more courses, the student's school number//(number from 0, i.e. 0,1,2, ...) is exported. And all of its course scores //the code I wrote/* #include <stdio.h>int main () { int i;struct student {int number;int math;int chinese;int english;int Physical;} Stu[5]; for (i=0;i<5;i++) { printf ("The student's study number is:"); &NBSP;SCANF ("%d", &stu[i].number); printf ("The student's math scores, language scores, English scores, physical results are:"); &NBSP;SCANF ("%d%d%d%d", &stu[i].math,&stu[i].chinese,&stu[i]. english,&stu[i].physical); } for (i=0;i<5;i++) if (stu[i].math<60| | stu[i].chinese<60| | Stu[i]. english<60| | stu[i].physical<60) { printf ("The school number of the failing student is:"), printf ("%d\n", Stu[i].number); printf (" All the grades of the failed students were: \ n "); printf (" Math:%d, language:%d, English:%d, Physics:%d\n ", stu[i].math,stu[i].chinese,stu[i). english,stu[i].physical); }return 0;} *///answer to the Code #include<stdio.h>void search (float (*p) [4],inT m) { int i,j,flag; for (i=0;i<m;i++) { flag=0; for (j=0;j<4;j++) if (* (* (p+i) +j) <60) flag=1; if (flag==1) { printf ("No.%d is flunked,scores are:\n ", i), for (j=0;j<4;j++) printf ("%5.1f ", * (* (p+i) +j)), printf (" \ n "); } }} Int main () {float score[5][4]={{65,80,78,90},{98,59,100,83},{92,66,78,70},{78,58,80,77},{64,68,70,81} };search (score,5); return 0;}
This article from "Peng Brother's Blog" blog, declined reproduced!
C Language Example Series--------14th Day