Home > Back-end > Input the number ten, with the first number will be the biggest
Input the number ten, with the first number will be the biggest
Time:12-18
Can you help me have a look at where is wrong,, //input 10 integers, one of the largest number with the number 1 #include using namespace std; Int main () { Void fun (int *); Int a [10], * p, I; P=a; for(i=0; i<10; I++) Cin> A, [I]. Fun (a); for(i=0; i<10; I++) Coutreturn 0; } Void fun (int * p) { Int I, j, t, k=0; For (I=k; i<9. I++) {
You this is a little trouble, if simply exchange the biggest and the first words, you can consider this, I changed the fun function on the basis of you,
# include using namespace std;
Void fun (int *);
Int main () { Int a [10], I; Cout & lt; <"Please input the number 10:" & lt; for (i=0; i <10; I++) { Cin & gt;> A, [I]. } Fun (a); Cout & lt; <"After the exchange:" & lt; for (i=0; i <10; I++) { Cout & lt; } return 0; } Void fun (int * p) { int k=0; For (int I=0; i <10; I++) { If (p [I] & gt; P [k]) { K=I; } } Int temp=p [0]; P=p [0] [k]. P=\ [k]; }