|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
代码如下:
#include <stdio.h>
//void max_array_number(int args_1,int args_2);
int main()
{
int array_int[10];
int max_array_number;
int max_array_index;
int array_index_1,array_index_2,array_index_3;
printf("please enter ten int number to the array:\n");
for (array_index_1 = 0; array_index_1 < 10; array_index_1++);
{
scanf("%d",&array_int[array_index_1]);
}
printf("\n");
printf("int number of the array:\n");
// int array_index_2;
for (array_index_2 = 0; array_index_2 < 10; array_index_2++)
{
//printf("%d\n",array_index_2);
printf("%d\t",array_int[array_index_2]);
}
//int array_index_3;
for (array_index_3 = 0,max_array_number = array_int[array_index_3]; array_index_3 < 10; array_index_3++)
{
if (max_array_number > array_int[array_index_3])
{
max_array_number = array_int[array_index_3];
max_array_index = array_index_3;
}
}
printf("the max number of the array_int is :%d,the index is %d",max_array_number,max_array_index+1);
return 0;
}
环境如下:
win10家庭版
D:\C\c_programming\exe>g++ -v
Reading specs from D:/MinGW/bin/../lib/gcc/mingw32/3.4.5/specs
Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.5
D:\C\c_programming\exe>
编辑工具:Visual Studio Code (Version:1.55.2(user setup));
cmd输入输出:
D:\C\c_programming\exe>7-9.exe
please enter ten int number to the array:
1 2 3 4 5 6 7 8 9 10
int number of the array:
4199424 6356704 1994162439 6356940 1994116288 -1525960463 -2 6356760 1994092333 4199424 the max number of the array_int is :-1525960463,the index is 6
D:\C\c_programming\exe>g++ -v |
|