应用2: 谁最大——有若干数字存入数组中,请找出最大值

xiaoxiao2025-03-13  8

问题及代码:

应用2: 谁最大——有若干数字存入数组中,请找出最大值

#include <stdio.h> #include <stdlib.h> #define SIZE 10 int main() { int d[SIZE]; int i,max,index; for(i=0; i<SIZE; i++) { scanf("%d",&d[i]); } max=d[0]; index=0; for(i=1; i<SIZE; i++) { if(d[i]>max) { max=d[i]; index=i; } } printf("The max number is %d .\n", max); printf("The index of the max number is %d .\n", index); return 0; }

 

转载请注明原文地址: https://www.6miu.com/read-5025779.html

最新回复(0)