2 like 0 dislike
6.7k views

This program will receive a sentence and reverse it as the result. 字串反轉

Example input 1:

School need Student

Example output 1:

Student need School

Example input 2:

Student

Example output 2:

Student

Example input 3:

are you as bored as I am

Example output 3:

am I as bored as you are

 

[Exam] asked in Final Exam
ID: 42298 - Available when: 2018-01-17 14:00 - Due to: Unlimited

retagged by | 6.7k views

30 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<string.h>


int main()
{
    char string[1000],reverse[1000];
    int index=0,len,wordstart,wordend,i;
    fgets(string,1000,stdin);
    len = strlen(string);

    wordstart=len-1;
    wordend=len-1;
    while(wordstart>0)
    {
*** ** * ** * *** ** * *** ** *** ***** * * * ** * ')
** ****** ******* ** ** *** ** ** * ** *
* * **** * ******** ** * ** ** ****** ***** * ** ***** *
* ** ** * * *** * * ** * ** ** * * ***** * * * * * * * * *** ***
**** * * ** ** **** * * **** ******** ** * * * * ** ** **
* ** * ** * * ****** ** *** **** * ** ** * *** * * * * * * ** * ***** * * * ** ** * * **** * ** * * **
** ****** * **** * **** * ** * **** ** * * * * ** ** * ** * * *** * ** ** *
* ** ** ** * **** * * ** * ** ** *** ** * * * * ** * ** * ** ***** * ** *** * **
* ** * * * * ** ** ***** ** * *** * ** * ***** * ** ** ****** *
* * * * * * * * * **** * ** * ** * * ** * ** * * *** ****** ***** ** * * ';
* ** ** ** ** *** * **** * * ***** * ** ** ** ** * *** **** * ** * **
* * * **** ** ** * * * **** * * ** ***
*** **** ** ** * ** ** ** *** *** * * *
    }
**** **** * ** ******* ***** ** * **
    {
*** * *** ** * *** ** *** * * * * * * **** ** * ***
* ** * ** ** ** * *** * * * * ***** * **** *
    }
    reverse[index]='\0';
* * * ** * ** *** * ** ** * *
*** ** * * ** * * *** ****** * * ** * ** ** * * * **
* * *** * ** *** * * ** *** *** *** **
    else
** * ****** * ** *** **** * * * * * ****** * ** **** * *

*** * ** * * ** ** ** *** ** ** * * ****** ** ** * ** ** * * ** **
** ** *** * ** ***** ** * * * * * **** *** ** ** **** * ***
**** * ** ** * ** **** ** ** * ** ** ** ** * ** * * * ** ** * *** ** **** *
* ** * * * ** * * * * ** ** ** * * * * * * * * * ** ***** * *** *** * * ** *
** * ** ** ** *** * * *** **** * * * * *** ** * **** * * * ** * * **
* * * ** ** * ***** ***** * * *** ** *** * * ** * ** * * *

* ** *** **** * * * **** ********* ** * * *** * ** * * * * * **** * ';
** *** ** * ** ** * * * ** * *** ** * ** ** *** *** * *** *** ** ** * **

******** ** ** *** **** ** **** * * * ****** *** * * * *

*** * ** * ***** * ** * ** * * *** **
    {
* ***** *** ** * * * * ** * * * ** ** *** *** * ***
** * * * **** * *** ****** * * ****** * **** * * ** *
    }

}
answered by (-140 points)
edited by
0 0
prog.c: In function 'main':
prog.c:17:27: error: stray '#' in program
             i=wordstart+1;#include<stdio.h>
                           ^
prog.c:17:28: error: 'include' undeclared (first use in this function)
             i=wordstart+1;#include<stdio.h>
                            ^~~~~~~
prog.c:17:28: note: each undeclared identifier is reported only once for each function it appears in
prog.c:17:36: error: 'stdio' undeclared (first use in this function)
             i=wordstart+1;#include<stdio.h>
                                    ^~~~~
prog.c:20:1: error: expected expression before 'int'
 int main()
 ^~~
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<string.h>

int main()
{
    char string[1000],reverse[1000];
    int index=0,len,wordstart,wordend,i;
** * * * **** * ** *** ***
    len = strlen(string);

*** **** * ** ** * * ** * ***
    wordend=len-1;
* ** *** ** * ** ** * ** ** *
    {
*** * ** ***** * * ** ** ** * *** * * ** * *** * * * * * ')
* **** * * * *** * ** ** *******
* ** ** * *** * *********** **** * *** *** *** * * ** ** * * **** ***
**** **** ** *** * * ** * * *** ** * *** ******* * * * *** **** *
**** * *** ** ** ** ** *** ** * * ** ** ** *** *** ** * *****
* ** * * * * * * * * * * * ** * ** * * ** * * * * * ******** ******** * ** * * ** *** *** **
***** ********** * ** ** * *** * * * * * * * * * * * * * * * * ** * * * *** ** ********
* * * * * * * *** * ** ** ** ** *** ** ** ** * *** * * * ** * **** * * *** *** *
** **** * * * *** ** * * ** * ** ** *** *** ** * ** * *******
*** * ** * ** ***** *** * * ** ******** * **** * * ** * * *** *** ** * ';
* **** **** * *** ** ***** ** * ** *** ** * * * *** ** * * * * * *
** * * * * * **** * * * * ** ** * * ***
* ** ** * ** ***** ** *** * * * * ** * * **
    }
* * ** **** *** **** ** * * * *
    {
***** * ** ** *** * * * *** * * ** *** **** * * * *
* * * * * ** ** ** *** * * **** * * * * * ** *
    }
*** ** ** * ** *
** * **** ** *** ** * *
* **** *** ** * ** * ** * * ** * ** ** **** * * * *
** *** ** * ****** ** ** * ** * **** * **
    else
* *** * ** *** * * * * * * ** * *** *** * * * * ** * *
}
answered by (-323 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
*** *
answered by (-284 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
* **** *** *** a[100];
***** * *** * * * * * ** ** * **** **
* * ** **** * * **** i,j,len = strlen(a);
* * * **** * ** = len-1 ; i >= 0 ; i--)
* * *** * * **** * *
** ** * ** ** * *** * * *** * * * ** ** *** == ' ')
* ** ** * * * ** * **** * ** * **** * *
* * *** * * *** * * *** *** ***** ** ****** ** ** * * * ** * * *** * = i+1 ; j < len ; j++)
*** * *** ** ** * ****** * * ** * ****** * * ** ** ** * ** *** *** ** *** *** * *** ** * ** ** * *
** * ** * ** * * * * * * **** **** * *** ** **** * ** * ****** ");
** *** * * ** * * * ** **** * * * * * * * *** **** ** ** = i;
** ** ** * ** * ** * *** ** * * ***
* * ** *** * *** ** * **
* * ** * * * * * = 0 ; i < len ; i++)
* *** ** * *** ** ** * * *** * * * ******* * * ** ***** *** **

**** **** * * *** ** * * * * * 0;
}
answered by (-255 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<string.h>
int main()
{
int i,j=0,t;
char a[100],*b[100];
fgets(a,100,stdin);
t=strlen(a);
for(i=0;i<t;i++){
** * ** * * * ***** * ***** ** *** * **
*** * **** * * *** **** ** ** * * ** * *** * * * **** * ** ** ** * * ** *
* *** * **** ** *** ** * *** ** *** * *
**** * * * ** ** * * ************* * ***** '){
* * **** * * * * **** * **** ***** **** * *** *** ** * * *
**** * * * ** * * *** **** ******* ** * * * * * * *** ******** *
**** *** *** * ** ** * **** * ** ** *** * * * ** * ******** * * *
* * * * ** * ** ** * * * * *** * **
    }
*** * * * * * *** ** ***** ** * ****
* * ** * * * * * ****** * **** * ** ** ***** ",b[j]);
** * * ** ** * ** ***
* *** * **** ** ***** ** ** *** * **
** * *** ** * * ****** **** 0;}
answered by (42 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include <string.h>
int main()
{
    int x,y=0,t;
    char p[100],*q[100];
*** * * ***** * * ******** * ** *** *
** *** * * * * *** ** * * *


* * * * * ** ** * *** ***** * *
** ***** * *** ** **** ** *** * *** * *** * * * * *****
* ** * * * *** ** ** * ** ** ** * * ** * ** * **** ** * ** * * *
** * ** ****** * *** * ** * * * * * ** ****

* * * ** * * * ** **** * ** ** ** ** ** * '){
** ** * * ** ** ** * * ** ** * *** * * * * * ** ** ** **** * * ** **
***** ** *** ******* ***** **** *** *** * ** * * ** ** ** * ****** *****
** ** ****** * ** * * * * * *** * ** * * *** * **** * * *
* ** ****** * * * * * ********* * ****
    }

* * * *** * * ******* * * * * * *
***** * ** **** ** * * ** ** * *** * * ** ** ",q[y]);
    }
*** * ** * * ***** ** * * * * *
** * * * * * * * ***** 0;
}
answered by (-107 points)
0 1
prog.c: In function 'main':
prog.c:8:7: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     t=strlen(p);
       ^~~~~~
prog.c:8:7: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:8:7: note: include '<string.h>' or provide a declaration of 'strlen'
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
* ** ** **** * * ***** ** ** * a[100];

***** ** * * ** * * * * **** * 100, stdin);

* ***** * * * *** * * len = strlen(a);

* * *** * *** * * * * * i = 0;

* ** ****** * ****** j = 0;

** * ** * ****** * = len - 1; i >= 0; i--)
** * * * ** * *** **** *
* * * ** * ****** * * ** ** * *** * * == ' ')
**** * **** ** * * *** * ** **** * * *** * *
* ** *** * * * *** * ***** * **** ** * ** * ** * * * ** = i + 1; j < len; j++)
* * ** ******* **** * * *** * * ** * **** * **** * **** ** ** * * * * * *
** ** ** * * *** ** *** *** *** ***** **** * ****** ******* ***** ** * * ** ** ******* * *** ***** ** a[j]);
***** ** ** *** * *** ** * *** ** *** *** * * *** * *** ** *** * *

** *** ******** * * * ** * * * ** *** * * ** ** ** ***** * * ** ");

** * *** ** ******** **** * ** ** * * ** ** * *** *** * * = i;
* ** * ** * *** * *** * ** * * * * *
* * **** ** * ******* * * *

** ** * * ** ******** ** * = 0; i < len; i++)
* * * ** ** ** * * * *
* ** * * *** *** ****** * *** *** * * ** * ** * a[i]);
    }
** * ***** * * * **** 0;
}
answered by (-285 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<string.h>
int main()
{
    int i,j=0,t;
    char a[100],*b[100];
* * * ** * * *** * *** ** *****
* ** * ** *** * * * *** *** **
* ** * * * * ******** * ** * * * *
* ** * * ** * * ** ** * *** *** * ** *** * *** *** *
**** ** * *** ** **** ** **** **** *** ***** * * ***** *** * * *
* * * *** *** **** * ** ***** ** *** ** * **
* * ** ** **** * * * * *** * *** ** * *** ** * '){
* * * * ** ** **** **** * *** ** ****** *** * * * * ***** * *
***** **** *** * *** * * ** ** *** ** ** * *** *** ** * * *** * *
* ** * *** * ** * ** ** * ** ** * * ***** **** ** * ****** * ** * * *****
**** * * ***** * * ** * * * **** * * * **
    }
* * * * **** * * *** * ** * * * * *
** * **** ** *** * ****** ** *** * ** *** ** * * ** ",b[j]);
    }
* ** * * * *** * * * * ***
** *** *** ** *** * * ** * ** 0;
}
answered by (54 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
*** ** ** **** **
* *** *** ****** *

int * **
{
* ***** * * ** *** * * * Park - Faint
* **** ** * * ** * **** * *** can't * * way I did *** *** turn your back on me. ****** *
* **** * * * *** ******* * *** ** be * * *** ** *** ** * **** * * **
*** * ** ** * * ******* turn your back on me \nI be ** * **** hear me out ** **** * *
* ** * *** ** * *** * * ***** ** got to * to me like it or not. * *** now. ** * me out * **
* * * *** ** * ** ** * **** got to * to me like it or not. * * *** *
* ** * ** * * * * *** * * ***** can't * ** * * way I did * ** *** turn your back on * * * ** be * * *** ** ***
* *** *** ** **** * ** * Park - Burn it down
** * ** *** *** **** ** * **** * *** it * * * it back ** * ** * it *** ** * * *
* ** * ** * *** ** * * burn it * * * * ***** burn it to the * * **** *
*** * * ** * * *** ** Park - ** *
* * * ** * * ** * * *** ** * * * in my * * ** * is how I ** ****** what is *** *
* * *** *** ** ** ** * Park - * to *
* * ** * * * *** * * ** *** * ** the * * * * just *** to * **** **
* ** ** * *** ** * * ** ** ** keep * like the sky is * ** \nI can * I can * * * I ** * *****
* ** ** * *** ** * * * *** I ** ** I *** just ** to * *** * to ** **** * ** *
* *** *** *** ***** ** **** * * * to * ***** I * * * I * * * I * * *** * to ** * *
** * * * ** *** ** * ** * * * * * have own *** song in * ** ** *** * **
** * ***** *** ** * * ** * * ** * * ** * *** **** * *
* ** * * ** * *** * * * *** 0;
}
answered by (-108 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main(){
** * *** **** ** ** str[20][50];
* * ** * **** ** * * ** i=0;
** * * * ** * ** ** * ** ** * ** ** * * *
* ** *** * ***** ** ** * * * ** *******
* * *****
*** ******* * ** * * *** *
** * * * * * ***** * *** * *** *
* * * * * * *** * ***** *
** * * * *** ** * * * * * *** * ** ** * ****** *** %s",str[i]);
    }
* * *** * * * * **** ** 0;
}
answered by (-116 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.254.192
©2016-2025

Related questions

1 like 0 dislike
37 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42302 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 8.6k views
2 like 0 dislike
31 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42301 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 7.5k views
1 like 0 dislike
32 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42300 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 8.7k views
1 like 0 dislike
37 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42299 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 8.3k views
0 like 0 dislike
12 answers
[Exam] asked Jan 19, 2018 in Final Exam
ID: 43459 - Available when: 2018-01-20 09:00 - Due to: Unlimited
| 2.7k views
12,783 questions
183,442 answers
172,219 comments
4,824 users