내 이름으로 문자열의 피라미드를 만들려고 노력 :안녕하세요. 임은 내가 할 노력하고있어
#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