给定一个整形数组(10个元素)求出最大值。

来源:互联网 发布:手机能注册淘宝邮箱吗 编辑:程序博客网 时间:2024/05/21 22:31
#include <stdio.h>#include <stdlib.h>int main(){int arr[10] = { 5, 6, 3, 2, 1, 4, 7, 9, 8 };int i;int max=0;for (i = 0; i < 10; i++){if (arr[i] >= max){max = arr[i];}}printf("max=%d\n", max);system("pause");return 0;}


运行结果:


阅读全文
0 0