[백준] 1526번 : 가장 큰 금민수 - C

강재원·2022년 10월 18일
0

[코딩테스트] C/C++

목록 보기
121/200



https://www.acmicpc.net/problem/1526

#include<stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
    char n[10];
    scanf("%s",n);
    while(1){
        int c=0;
        for(int i=0;i<strlen(n);i++){
            if(n[i]!='4' && n[i]!='7'){
                c=1;
                break;
            }
        }
        if(c==0) break;
        else sprintf(n,"%d",atoi(n)-1);
    }
    printf("%s",n);
}
profile
개념정리 & 문법 정리 & 알고리즘 공부

0개의 댓글