Home > Back-end >  inquire
inquire

Time:10-04

Why in the following code commit on professional system has a problem, said there is abnormal,
Will the capitalize the first letter of the string
#include

Int main ()
{
Char a, [50].
int i,n;
For (I=0; i<50; I++)
{
The scanf (" % c ", & amp; A [I]);
If (a [I]=='\ n') break;
}
N=I;

If (a [0] <='z' & amp; & A [0] & gt;
='a'){
A [0]=a, [0] - 32.
}
for(i=1; i{
If (a=[I - 1]=' ')
{
If (a [I] & gt;='a' & amp; & A [I] <='z')
{
A [I]=a, [I] - 32.
}
}
}
For (I=0; i{
Printf (" % c ", a [I]);
}
return 0;
}

CodePudding user response:

What is abnormal
 char a, [50]. 
Int I, n;
for (i=0; I & lt; 50; I++)
{
The scanf (" % c ", & amp; A [I]);
If (a [I]=='\ n')
break;
}
N=I;

If (a [0] <='z' & amp; & A [0] & gt;
='a'){
A [0]=a, [0] - 32.
}
For (I=1; I & lt; n; I++)
{
If (a=[I - 1]=' ')
{
If (a [I] & gt;='a' & amp; & A [I] <='z')
{
A [I]=a, [I] - 32.
}
}
}
for (i=0; I & lt; n; I++)
{
Printf (" % c ", a [I]);
}

CodePudding user response:

Say timeout or memory what, do you can compile and problems in its submission system

CodePudding user response:

 # include & lt; stdio.h> 
# define N 20//////////////////

Int main () {
Char a, [N].///////
int i,n;
For (I=0; iThe scanf (" % s ", a [I]);/////////////
If (a [I]=='\ n') break;
}
N=I;

If (a [0] <='z' & amp; & A [0] & gt; {
='a')A [0]=a, [0] - 32.
}
for(i=1; iIf (a=[I - 1]=' ') {
If (a [I] & gt;='a' & amp; & A [I] <='z') {
A [I]=a, [I] - 32.
}
}
}
//for (I=0; iPrintf (" % s ", a);//////////
//}
return 0;
}

Ok
Don't

CodePudding user response:

Normal, should have no problem