0
Why it give me " No Output" ????
#include <iostream> using namespace std; int main() { string a,b; cin >> a ; int a1 = a.size () ; int j = 0 ; for (int i = a1 ; i<0 ; i++) { b[j] = a[i] ; j++ ; } cout <<b; return 0; }
3 Respostas
+ 3
#include <iostream>
using namespace std;
int main () {
string a;
cin >> a;
for (int i = a.size() - 1; i >= 0; i--) {
cout << a[i];
}
return 0;
}
+ 3
in the for cyclus you should decrease i, if you want to reverse the input.
i--
j and b are not needed
+ 1
there might be other issues not sure but for your for loop you have int i = a1;i<0;i++. I think you want int i = 0;i<a1;i++. because currently the loop isnt running at all since its checking if i is less then 0 it will continue the loop yet it starts at a number higher then 0. hope this helped somewhat. edit: just realized if your trying to reverse the string i = a1;i>0;i--