문자를 입력받아서 10줄에 1열씩 옮겨가며 출력하기.
#include <iostream>
#include <windows.h>
using namespace std;
int main(){
char a,i,j;
cin>>a;
for(i=0;i<10;i++){
for(j=0;j<10;j++){
if(j==i) cout<<a;
else cout<<".";
}
cout<<endl;
}
system("PAUSE");
return 0 ;
}
실행결과
Q
Q.........
.Q........
..Q.......
...Q......
....Q.....
.....Q....
......Q...
.......Q..
........Q.
.........Q
Press any key to continue . . .
#include <iostream>
#include <windows.h>
using namespace std;
int main(){
char a,i,j;
cin>>a;
for(i=0;i<10;i++){
for(j=0;j<10;j++){
if(j==i) cout<<a;
else cout<<".";
}
cout<<endl;
}
system("PAUSE");
return 0 ;
}
실행결과
Q
Q.........
.Q........
..Q.......
...Q......
....Q.....
.....Q....
......Q...
.......Q..
........Q.
.........Q
Press any key to continue . . .
댓글
댓글 쓰기