정보올림피아드 삼각형다루기1

잡다한얘기 2013. 3. 10. 20:10

#include<iostream>
using namespace std;
void Form1(int n);
void Form2(int n);
void Form3(int n);
int main(void)
{
//길이,종류
int num1,num2;
cin>>num1>>num2;
if(num1 <= 100)
{
switch(num2)
{
case 1:
Form1(num1);
break;
case 2:
Form2(num1);
break;
case 3:
Form3(num1);
break;
default:
cout<<"INPUT ERROR!"<<endl;
break;
}
}
else
{
cout<<"INPUT ERROR!"<<endl;
}
}
void Form1(int n)
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
cout<<'*';
}
cout<<endl;
}
}
void Form2(int n)
{
int temp = n;
for(int i=1;i<=n;i++)
{
for(temp;temp>=i;temp--)
{
cout<<'*';
}
temp = n;
cout<<endl;
}
}
void Form3(int n)
{
int result =1;
int j= 1;
int temp = n;
int s=0;
for(int i=1;i<=n;i++)
{

for(j;j<=result;j++)
{
for(temp;temp>0;temp--)
cout<<' ';
cout<<'*';

}
++s;
temp = n;
temp -= s;
result = j+(2*i);
cout<<endl;
}
}

 

해석해보시기 바라구요 !!

밑은 컴파일된 스샷입니다.

 

 

 

 

'잡다한얘기' 카테고리의 다른 글

정보올림피아드 실력다지기2번문제  (0) 2013.03.10
우파루마운틴 조합법 + 알모양  (0) 2013.02.22

설정

트랙백

댓글