Home > Back-end > Just learning c language, the trouble, and see what's the problem!
Just learning c language, the trouble, and see what's the problem!
Time:01-05
Title: design function, according to ASCII for two-dimensional maximum and minimum values of an array of characters, requirements: use global variables the Max and Min to the maximum and the minimum storage requirements; #include The char Max, Min, Int main () { Void swap (char a [80] [80]). int i, j; Char a [80] [80]. for(i=0; i<80; I++) For (j=0; J & lt; 80; J++) { The scanf (" % c \ n ", & amp; A [I] [j]); } Printf (" Max Min=c=% % c ", Max, Min); return 0; } Void swap (char a [80] [80]) { int i, j; Max=a [0] [0]; Min=a [0] [0]; for(i=0; i<80; I++) For (j=0; i <80 j++) { If (Max & lt; A [I] [j]) Max=a, [I] [j]. If (Min & gt; A [I] [j]) Min=a, [I] [j]. } } Compiler error, but haven't output is why input characters and press enter
CodePudding user response:
Reference:
# include
The char Max, Min,
Int main () { Void swap (char a [80] [80]). Int I, j; Char a [80] [80]. for(i=0; i<2; I++) For (j=0; J & lt; 2; J++) { The scanf (" % c ", & amp; A [I] [j]);//the scanf (" % c \ n ", & amp; A [I] [j]); } Swap (a);//function call
Printf (" Max Min=c=% % c \ n ", Max, Min);
return 0; } Void swap (char a [80] [80]) { int i, j; Max=a [0] [0]; Min=a [0] [0]; for(i=0; i<2; I++) For (j=0; J & lt; 2; J++)//for (j=0; i <2; J++) { If (Max & lt; A [I] [j]) Max=a, [I] [j]. If (Min & gt; A [I] [j]) Min=a, [I] [j]. } }
CodePudding user response:
Forget changed back to 80:
# include
The char Max, Min,
Int main () { Void swap (char a [80] [80]). Int I, j; Char a [80] [80]. for(i=0; i<80; I++) For (j=0; J & lt; 80; J++) { The scanf (" % c ", & amp; A [I] [j]);//the scanf (" % c \ n ", & amp; A [I] [j]); } Swap (a);//function call
Printf (" Max Min=c=% % c \ n ", Max, Min);
return 0; } Void swap (char a [80] [80]) { int i, j; Max=a [0] [0]; Min=a [0] [0]; for(i=0; i<80; I++) For (j=0; J & lt; 80; J++)//for (j=0; i <2; J++) { If (Max & lt; A [I] [j]) Max=a, [I] [j]. If (Min & gt; A [I] [j]) Min=a, [I] [j]. } }