Home > Back-end >  Program is for the purpose of the user input sentences upside down output, sen an array used to stor
Program is for the purpose of the user input sentences upside down output, sen an array used to stor

Time:09-22

#include
Int main () {
int i=0;
Char sentence [I];
Int j=0; Printf (" input a English sentence: ");

For ((what [I]=getchar ())='? '& & What [I]='! '& & What [I]!='. '; I++) {
;
}
Char sen_last=what [I];
Printf (" reverse the order of the sentence is: ");
int k=0;
int m;
Char sen [k].
For (j=I - 1; J>=0; J -, k++) {
Sen [k]=what [j];
If (sen [k]=='| | sen [k]==', ') {
For (m=k; M>=0; M -) {
Putchar (sen [m]);
}
k=0;
}
}
printf("\n");
Printf (" % d % d \ n ", j, k);
return 0;
}


Program is 14 questions out of the book

CodePudding user response:

for(; (what [I]=getchar ())!='? '& amp; & What [I]!='! '& & What [I]!='. '; I++) {
;
}

CodePudding user response:

reference 1st floor weixin_40290083 response:
for (; (what [I]=getchar ())!='? '& amp; & What [I]!='! '& & What [I]!='. '; I++) {
;
}

What's the problem??

CodePudding user response:

Question 1
Don't use variable defined array length
The char sentence [I] to char sentence [256]

Question 2
For loop conditions do not use=, but==,
=='? '& amp; &=='! '& amp; &=='. '

Question3:
You are upside down character to be a whole sentence or words upside down? Now you sen [k]=sentance [j] it is character,

CodePudding user response:

refer to the second floor of Laplace's demon reply:
Quote: refer to 1st floor weixin_40290083 response:
for (; (what [I]=getchar ())!='? '& amp; & What [I]!='! '& & What [I]!='. '; I++) {
;
}

What's the problem??


Comparing this code and your code, be careful! Careful!!!!! Be patient!!!!!!

CodePudding user response:

What [I] is not a variable-length array declaration? The equal sign is actually!=but because I was using a mobile phone directly on the copy and paste, so lead to incomplete code

CodePudding user response:

Ok

CodePudding user response:

How to ask again, mobile CSDN BBS others integral
  • Related