に私の名前を持つ文字列のピラミッドをしよう:こんにちは。イムは、私が何をしようとしていること
#include<iostream>
#include<string>
using namespace std;
int main(){
string st("HabibRehman");
string a="", b="";
int y=st.length();
int d=y/2;
int f;
f=d;
for(int i=1;i<st.length();i++){
for(int j=0;j<y;j++){
cout<<" ";
}
for(int k=0;k<1;k++)/*I'm not sure what this loop should be*/{
cout<<a+st.substr(d,i)<<endl;
/*int d=(st.length()/2);
static int f=d;//I was trying to keep the values static here
static int g=d;*/
//this doesn't work in here
}
--f;//if i put this outside the for loop it works wrong without the termination error.
a=st.substr(f,i);//I'm using this to get the value prior to the st.substr(d,i)
y--;
}
system("pause");
return 0;
}
私は終了エラーを取得しておきます。 Iveは、ループ、サブストリングと変数の位置を変更したいと思っていたほとんどすべてを試しました。私が望む出力が得られたら、プログラムは私に終了エラーを返します。
あなたのやりたいことははっきりしません。私はイメージが欠けていると思う。 – Chiel
'[画像が表示され続けるエラーを表示します]は、コンパイルエラーを発します。削除すると、 'f'が負になり、範囲外のエラーが発生します。 – MikeCAT
テキスト出力を画像として画像に追加しないでください!あなたの質問のテキストとして(そして適切な場所に)してください。 – usr2564301