+ 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;} }
2 Réponses
0
@~ swim ~
now can u try it?? i fixed it