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].
}
}

CodePudding user response:

refer to the second floor QZJHJXJ 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].
}
}

Thanks, but I don't know why not changed back after 80, it is 2 words can

CodePudding user response:

reference qq_54217290 reply: 3/f
Quote: refer to the second floor QZJHJXJ 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].
}
}

Thanks, but I don't know why not changed back after 80, it is 2 words can

Change back to 80, you must be a one-time input 80 * 80=6400 characters, to conform to the requirements of your input, you type so much?

CodePudding user response:

QZJHJXJ
reference 4 floor response:
Quote: refer to the third floor qq_54217290 response:
Quote: refer to the second floor QZJHJXJ 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

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related