#include <stdio.h>/* userCode(<80字符):自定义函数之原型声明 */i
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/10 13:56:41
#include <stdio.h>
/* userCode(<80字符):自定义函数之原型声明 */
int fun(int arr[5][9]);
int main(void)
{
\x05int array[5][9],i,j,max,maxRow,maxCol;
\x05printf("Input matrix:\n");
\x05for (i=0; i<5; i++)
\x05{
\x05\x05for (j=0; j<9; j++)
\x05\x05{
\x05\x05\x05scanf("%d",&array[i][j]);
\x05\x05}
\x05}
\x05/* userCode(<80字符):调用函数查找数组中最大元素及其所在位置的行下标、列下标 */
\x05max = fun(array);
\x05maxRow = fun(array);
\x05maxCol = fun(array);
\x05printf("\nThe max is %d,row-sub is %d,col-sub is %d\n",max,maxRow,maxCol);
\x05return 0;
}
/* User Code Begin:考生在此后完成自定义函数的设计,行数不限 */
int fun(int arr[5][9])
{
\x05int i,j,Max,Maxi,Maxj;
\x05Max = arr[0][0];
\x05for (i = 0; i < 5; i++)
\x05{
\x05\x05for (j = 0; j < 9; j++)
\x05\x05{
\x05\x05\x05if (Max < arr[i][j])
\x05\x05\x05{
\x05\x05\x05\x05Max = arr[i][j];
\x05\x05\x05\x05Maxi = i;
\x05\x05\x05\x05Maxj = j;
\x05\x05\x05}
\x05\x05}
\x05}
\x05return Max;
}
maxRow = fun(array);
maxCol = fun(array);
maxRow maxCol 不能这么取.
可以修改fun函数
int fun(int arr[][9],int *row,int *col)
maxRow maxCol可以从这两个新加的参数获取.
max = fun(array,&maxRow,&maxCol);
int (int arr[][9], int *row, int *col)
{
\x05int i, j, Max;
\x05Max = arr[0][0];
\x05for (i = 0; i < 5; i++)
\x05{
\x05\x05for (j = 0; j < 9; j++)
\x05\x05{
\x05\x05\x05if (Max < arr[i][j])
\x05\x05\x05{
\x05\x05\x05\x05Max = arr[i][j];
\x05\x05\x05\x05*row = i;
\x05\x05\x05\x05*col = j;
\x05\x05\x05}
\x05\x05}
\x05}
\x05return Max;
}
maxCol = fun(array);
maxRow maxCol 不能这么取.
可以修改fun函数
int fun(int arr[][9],int *row,int *col)
maxRow maxCol可以从这两个新加的参数获取.
max = fun(array,&maxRow,&maxCol);
int (int arr[][9], int *row, int *col)
{
\x05int i, j, Max;
\x05Max = arr[0][0];
\x05for (i = 0; i < 5; i++)
\x05{
\x05\x05for (j = 0; j < 9; j++)
\x05\x05{
\x05\x05\x05if (Max < arr[i][j])
\x05\x05\x05{
\x05\x05\x05\x05Max = arr[i][j];
\x05\x05\x05\x05*row = i;
\x05\x05\x05\x05*col = j;
\x05\x05\x05}
\x05\x05}
\x05}
\x05return Max;
}
#include <stdio.h>/* userCode(<80字符):自定义函数之原型声明 */i
#include <stdio.h>
一道c语言题,#include<stdio.h>#include<string.h>#inclu
while语句!#include <stdio.h>#include <windows.h>in
运行后的图是:#include <stdio.h>#include <stdlib.h>void
转置矩阵#include <stdio.h> #include <stdlib.h>
#include <stdio.h> #include <iostream> int main(
#include<stdio.h> main() { int i=2,x; x=i++-++i; print
c语言编程计算数列合#include <stdio.h> #include &
C语言高手帮我填空#include <stdio.h>#include
include<stdio.
求M和N最大公约数?#include<stdio.h>void main(){ &nbs