一个程序来反转字符串中的每个单词(我阅读了以前的解决方案,但我正在寻找一个使用我只在这里的功能的程序
a program to reverse each word in a string( ive read the previous solutions but im looking for one using the functions i only here
我写过这个 C 程序,但我总是收到与输出相同的输入句子,没有任何变化!我已经拆分了字符串中的每个单词,然后反转了它们的位置,但效果不佳!请提供任何解决方案!
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main ()
{
char A[81][81];
int t=0,j=1,k=0,l;
puts("Input a sentence (max 80 character)");
gets(A[0]);
while (A[0][t]!='[=10=]')
{
if(A[0][t]=='')
{
j++;
t++;
k=0;
}
A[j][k]=A[0][t];
k++;
t++;
}
for (l=j;l>0;l--)
{
printf("%s",A[l]);
}
getch();
}
#include <stdio.h>
#include <string.h>
#include <conio.h>
int main(void){
char A[81][81] = {0};
int t=0,j=1,k=0,l;
puts("Input a sentence (max 80 character)");
scanf("%80[^\n]", A[0]);//'gets' has already been abolished, it should explore a different way.
while (A[0][t] != '[=10=]'){
if(A[0][t] == ' '){
++j;
k=0;
while(A[0][t] == ' ')//Skip spaces
++t;
} else {
A[j][k++] = A[0][t++];
}
}
for (l=j;l>0;l--){
printf(" %s",A[l]);
}
puts("");
getch();
}
我写过这个 C 程序,但我总是收到与输出相同的输入句子,没有任何变化!我已经拆分了字符串中的每个单词,然后反转了它们的位置,但效果不佳!请提供任何解决方案!
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main ()
{
char A[81][81];
int t=0,j=1,k=0,l;
puts("Input a sentence (max 80 character)");
gets(A[0]);
while (A[0][t]!='[=10=]')
{
if(A[0][t]=='')
{
j++;
t++;
k=0;
}
A[j][k]=A[0][t];
k++;
t++;
}
for (l=j;l>0;l--)
{
printf("%s",A[l]);
}
getch();
}
#include <stdio.h>
#include <string.h>
#include <conio.h>
int main(void){
char A[81][81] = {0};
int t=0,j=1,k=0,l;
puts("Input a sentence (max 80 character)");
scanf("%80[^\n]", A[0]);//'gets' has already been abolished, it should explore a different way.
while (A[0][t] != '[=10=]'){
if(A[0][t] == ' '){
++j;
k=0;
while(A[0][t] == ' ')//Skip spaces
++t;
} else {
A[j][k++] = A[0][t++];
}
}
for (l=j;l>0;l--){
printf(" %s",A[l]);
}
puts("");
getch();
}