뉴비의 천방지축 IT 블로그

Programing/Baekjoon 백준

백준 5단계 C 풀이

recognizee 2022. 11. 13. 17:33
728x90

5 - 1단계 (15596번)

15596번


더보기

long long sum(int *a, int n){
    long long s=0;
    for(int i=0;i<n;i++){
        s+=a[i];
    }
    return s;
}


 

5 - 2단계 (4673번)

4673번


더보기

#include<stdio.h>
int d(int n){
    int sum=n;
    while(n>0){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}
int main(){
    int n[10001], r;
    for(int i=0;i<10001;i++){
        r=d(i);
        if(r<10001) n[r]=1;
    }
    for(int i=1;i<10001;i++){
        if(n[i]!=1) printf("%d\n",i);
    }
    return 0;
}


 

5 - 3단계 (1065번)

1065번


더보기

#include<stdio.h>
void abc(int n){
    int c=0;
    for(int i=1;i<n+1;i++){
        if(0<i&&i<100) c++;
        else if(i<1000){
            int r=(i%100)/10-(i%10);
            if(((i%1000)/100)-((i%100)/10)==r && (i%100)/10-(i%10)==r) c++;
        }
    }
    printf("%d",c);
}
int main(){
    int n;
    scanf("%d",&n);
    abc(n);
    return 0;
}


 

'Programing > Baekjoon 백준' 카테고리의 다른 글

백준 9단계 C 풀이  (0) 2022.11.13
백준 4단계 C 풀이  (1) 2022.11.08
백준 3단계 C 풀이  (0) 2022.11.06
백준 2단계 C 풀이  (0) 2022.10.30
백준 1단계 C 풀이  (0) 2022.10.30