BOJ 10818 최소, 최대

1 개요[ | ]

BOJ 10818 최소, 최대


2 C++[ | ]

#include <iostream>
using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    int num;
    int max = -1000000;
    int min = 1000000;
    for(int i=0; i<N; i++) {
        scanf("%d", &num);
        if( num > max ) max = num;        
        if( num < min ) min = num;        
    }
    cout << min << ' ' << max << '\n';
}
#include <iostream>
using namespace std;

int main() {
    int N;
    cin >> N;
    int num;
    int max = -1000000;
    int min = 1000000;
    for(int i=0; i<N; i++) {
        cin >> num;
        if( num > max ) max = num;        
        if( num < min ) min = num;        
    }
    cout << min << ' ' << max << '\n';
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}