+ 1

why this code not printing string in pyramid pattern??

#include <iostream> #include <string> #include <algorithm> using namespace std; int main() {string userinput; cout<<"Enter your text :\n "; getline(cin,userinput); int n=userinput.length(); for (int i=0;i<=userinput.length();i++) {cout<<string(n,' ')<<userinput.substr(0,i); string str2 = userinput.substr(0,i); reverse(str2.begin(),str2.end()); if(i>=1) {cout<<str2.substr(1)<<endl;} n -= 1;} }

20th May 2019, 6:12 AM
Venkatesh
2 Antworten
0
@~ swim ~ now can u try it?? i fixed it
20th May 2019, 7:27 AM
Venkatesh