U E D R , A S I H C RSS

데블스캠프2006/월요일/연습문제/for/이차형

No older revisions available

No older revisions available



데블스캠프2006/월요일/연습문제/for/이차형

첫번째
~cpp
#include <iostream.h> 

int main() 
{ 
    int i; 
    int j; 
    int n; 

    cout <<"삼각형의 층수 : "; 
    cin >>n; 

    cout <<"\n"; 
    cout << n; 
    cout << "층짜리 직삼각형\n\n"; 

    for(i=1;i<=n;i++) 
    { 
        for(j=1;j<=i;j++) 
        { 
            cout<<"*"; 
        } 
        cout<<"\n"; 
    } 

    cout <<"\n"; 
    cout << n; 
    cout <<    "층짜리 역직삼각형\n\n"; 

    for(i=1;i<=n;i++) 
    { 
        for(j=n;j>=i;j--) 
        { 
            cout<<"*"; 
        } 
        cout<<"\n"; 
    } 

    return 0; 
} 

두번째
~cpp
#include <iostream.h> 

int main() 
{     
    int num; 
     
    int i; 
    int mul=1; 

    cout <<"fac (0<=fac<=10) : "; 
    cin >> num; 

    if(num<=10) 
    { 
        for(i=1; i<=num; i++) 
        { 
            mul=mul*i; 
        } 
        cout << mul; 
        cout << "\n"; 
    } 
    else 
    { 
        cout<<"범위를 잘못 입력하셨습니다."; 
    } 

    return 0; 
} 

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:03
Processing time 0.0188 sec