+ 3
Challenge 12: String Reversal with a Difference.
Write a program to input a string consisting of more than one word. Reverse the order of words in the string without altering the words, number of spaces, etc. If the string consists of exactly one word, display an error message. A word is any set of characters succeeded by a space.
14 Réponses
+ 9
Late by 2 minutes 😔. My try:
https://code.sololearn.com/WFBwDwWlokEW/?ref=app
+ 7
// with JavaScript
function rev_sentence(sentence){
var tokens = sentence.trim().split(' ');
if(tokens.length <= 1){
return 'error';
}
return tokens.reverse().join(' ');
}
alert(rev_sentence(prompt('enter a string')));
+ 3
: try my here https://code.sololearn.com/W5ScWQu3K68x/?ref=app
beside, here is a propose challenge :)
https://www.sololearn.com/Discuss/635638/?ref=app
+ 3
Guys...Help me out where i am missing .
My code prints the reverse letter by letter.I am tried in C.Code Goes here.,, Amerandra challenge.
void main(){
char[30],rev[30];
printf("Enter the string");
gets(str);
strcpy(rev,str);
strrev(rev);
printf("reverse is %s", rev);
}
o/p : given string - solo learn
The out put is = nrael olos.
+ 3
Here you go, amigo. Have a nice weekend.
https://code.sololearn.com/W17T02MuReH3/#js
+ 3
here is my try I know I am not good at coding but I try to do code in good way😊😊
https://code.sololearn.com/cYWEHK64RNDA/?ref=app
+ 2
Here you go.
https://code.sololearn.com/c0WY49Ep7iad/?ref=app
+ 2
Here is my try
https://code.sololearn.com/cUXXqc349rIa/?ref=app
+ 2
Here's some Python
https://code.sololearn.com/c5fK88JCcEC3
+ 1
heres mine 2 line in python
https://code.sololearn.com/c02Tiarq2ixo/?ref=app
0
@Burey, could you attach a Sololearn code for this.
I am too lazy to copy yours and test it in the Code Playground...😄😄😄
- 1
HERES THE NEW CHALLENGE...
CHECK IT OUT FRIENDS
https://www.sololearn.com/discuss/653982/?ref=app