+ 1
Can someone pls đ help.I am working on secret messages. I need hint đ€. Senior programmers,pls help your little boy đ
include <iostream> using namespace std; string Reversed_Alpha(string X){ string Nword; string O_alpha="abcdefghijklmnopqrstuvwxyz",Co_alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ",U_alpha="zyxwvutsrqponmlkjihgfedcba"; for(int i=0;i<X.size();i++){ for(int k=0;k<=25;k++){ if(X[i]==O_alpha[k]||X[i]==Co_alpha[k]){ X[i]=U_alpha[k]; Nword+=X[i]; } } } return Nword ; } int main() { string word; cin>>word ; cout<<Reversed_Alpha(word); return 0; }
7 Answers
+ 1
Actually the "#include " is there.
But how do I use the getline() function?
I'm asking this because the getline () function is not added in the c++ lesson.
Pls, put me through đ€.
+ 1
Manav Roy
Have tried it but still not giving the correct output
+ 1
YeahđȘ,I have solved it. The code goes thus:
#include <iostream>
using namespace std;
string Reversed_Alpha(string X){
string Nword;
string O_alpha="abcdefghijklmnopqrstuvwxyz ",Co_alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ ",U_alpha="zyxwvutsrqponmlkjihgfedcba ";
for(int i=0;i<X.size();i++){
for(int k=0;k<=26;k++){
if(X[i]==O_alpha[k]||X[i]==Co_alpha[k]){
X[i]=U_alpha[k];
Nword+=X[i];
break;
}
}
}
return Nword;
}
int main() {
string word;
getline(cin,word);
cout<<Reversed_Alpha(word);
return 0;
}
+ 1
Thanks Manav Roy
+ 1
Manav Roy
Which method did you use to solve yours?
Is this not the usage of characters?
0
Ooh thanks
Learning never end .
tolower() function đ€
0
Manav Roy I made some adjustments to the example you provided - Same functionality, just a bit cleaner.
https://code.sololearn.com/c56W1wdhRPSS/?ref=app