#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
#define _CRT_SECURE_NO_WARNINGS

int cnt[50001];

int main() {
    
    //freopen("input.txt", "rt", stdin);
    int n, i, j;
    scanf("%d",&n);
    
    for(i=1; i<=n; i++) {
        for(j=1; j<=n; j=j+i) {
            cnt[j]++;
        }
    }
  
    for(i=1; i<=n; i++) {
        printf("%d ", cnt[i]);
    }
  
    return 0;
}

블로그 이미지

wtdsoul

,

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
#define _CRT_SECURE_NO_WARNINGS

int main() {
    
    //freopen("input.txt", "rt", stdin);
    char a[100];
    int i, cnt = 0;
    
    scanf("%s", &a);
    for(i=0; a[i]!= '\0'; i++) {
        if(a[i] == '(' ) cnt++;
        else if(a[i] == ')' ) cnt--;
        if(cnt < 0) break;
        
    }
    
    if(cnt == 0) printf("YES\n");
    else printf("NO\n");
    
    
    return 0;
}

 

 

블로그 이미지

wtdsoul

,


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
#define _CRT_SECURE_NO_WARNINGS

int main() {
    
    //freopen("input.txt", "rt", stdin);
    char a[101], b[101];
    int i, p = 0;
    
    gets(a); 
    for(i= 0; a[i]!='\0'; i++) {
        if(a[i] != ' ') {
            if(a[i] >= 65 && a[i] <= 90) {
                b[p++] = a[i]+32;
            }
            else b[p++] = a[i];
        }
    
    }
    b[p] = '\0';
    printf("%s\n", b);
    
    return 0;
}


 

 

'코딩테스트' 카테고리의 다른 글

모두의 약수 (제한시간 1초)  (0) 2024.09.17
올바른 괄호 (문자열 컨트롤)  (0) 2024.09.17
숫자만 추출 (문자열 컨트롤)  (0) 2024.09.17
나이 계산 (문자열 컨트롤)  (0) 2024.09.17
나이 차이 계산  (0) 2024.09.16
블로그 이미지

wtdsoul

,

#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
    
    //freopen("input.txt", "rt", stdin);
    char a[100];
    int res = 0, cnt = 0, i;
    
    scanf("%s", &a);
    for(i=0; a[i] != '\0'; i++) {
        if(a[i] >= 48 && a[i]<= 57)
            res = res * 10+(a[i]-48);
    }
    
    printf("%d\n", res);
    for(i=1; i<= res; i++) {
        if(res % i == 0) cnt++;
    }

    printf("%d\n", cnt);
    
    
    return 0;
}

 

블로그 이미지

wtdsoul

,


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

int main() {
    
    //freopen("input.txt", "rt", stdin);
    char a[20];
    int year, age;
    
    scanf("%s",&a);
    if(a[7] == '1' || a[7] == '2') year=1900 + ((a[0]-48)*10+(a[1]-48))  // char 48 빼기 
    else year = 2000 + ((a[0]-48) * 10 + (a[1]-48));
    
    age = 2019 - year + 1;
    printf("%d ", age);
    if(a[7] == '1' || a[7] == '3') printf("M\n");
    else pritnf("W\n");
    

    return 0;
}

블로그 이미지

wtdsoul

,

 


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;
#include <stdbool.h>
#include <stdlib.h>

int main() {
    
    int n, i, a, max = -2147000000, min = 2147000000;
    cin>>n;
    
    for(i=1; i<= n; i++) {
            cin >> a;
            if(a > max) max = a;
            if(a < min) min = a;
        
    }
    cout<< max- min;
        

}

 

 

'코딩테스트' 카테고리의 다른 글

숫자만 추출 (문자열 컨트롤)  (0) 2024.09.17
나이 계산 (문자열 컨트롤)  (0) 2024.09.17
1부터 N까지의 M의 배수의 합  (0) 2024.09.16
1부터 N까지의 M의 배수합  (0) 2024.09.16
성적표  (0) 2024.09.16
블로그 이미지

wtdsoul

,

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main () {
    
    int n, m, i, sum=0;
    cin>>n>>m;
    
    for(i=1; i<=n; i++) {
        if(i%m == 0){
            sum = sum + i;
        }
    }
    cout<<sum;

return 0;
}

 

'코딩테스트' 카테고리의 다른 글

나이 계산 (문자열 컨트롤)  (0) 2024.09.17
나이 차이 계산  (0) 2024.09.16
1부터 N까지의 M의 배수합  (0) 2024.09.16
성적표  (0) 2024.09.16
배열의 최소값 리턴  (0) 2024.09.16
블로그 이미지

wtdsoul

,

 

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main () {
    
    int n, m, i, sum=0;
    cin>>n>>m;
    
    for(i=1; i<=n; i++) {
        if(i%m == 0){
            sum = sum + i;
        }
    }
    cout<<sum;

return 0;
}

'코딩테스트' 카테고리의 다른 글

나이 차이 계산  (0) 2024.09.16
1부터 N까지의 M의 배수의 합  (0) 2024.09.16
성적표  (0) 2024.09.16
배열의 최소값 리턴  (0) 2024.09.16
자릿 수 출력  (0) 2024.09.16
블로그 이미지

wtdsoul

,

성적표

코딩테스트 2024. 9. 16. 21:58


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>

struct Student {
    int n, mat, eng, c;
      
};

int main() {
    Student s[51];  //  51개 배열 
    int i, n, max = - 2147000000, res;
    scanf("%d", &n);
    for(i=1; i<= n; i++) {
        scanf("%d", &s[i].n);
        scanf("%d", &s[i].mat);
        scanf("%d", &s[i].eng);
        scanf("%d", &s[i].c);
    }
    for(i=1; i<=n; i++) {
        if(s[i].mat > max) {
            max = s[i].mat; 
            res = s[i].c;
        }
    }
    printf("%d\n", res);
    

return 0;
}

'코딩테스트' 카테고리의 다른 글

1부터 N까지의 M의 배수의 합  (0) 2024.09.16
1부터 N까지의 M의 배수합  (0) 2024.09.16
배열의 최소값 리턴  (0) 2024.09.16
자릿 수 출력  (0) 2024.09.16
소수 찾기  (0) 2024.09.16
블로그 이미지

wtdsoul

,


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>

// tmp 매개변수도 첫 번째 주소지로 받는다.

int Min(int tmp[], int size) {
    int i, res=2147000000;
    for(i=0; i<size; i++) {
        if(tmp[i]<res) res=tmp[i];
    }
    
    return res;


int main(){
int n, i, a[101];

scanf("%d", &n);
for(i=0; i < n; i++) {
    scanf("%d", &a[i]);
}

printf("%d\n", Min(a, n));
return 0;
}

 

 

'코딩테스트' 카테고리의 다른 글

1부터 N까지의 M의 배수합  (0) 2024.09.16
성적표  (0) 2024.09.16
자릿 수 출력  (0) 2024.09.16
소수 찾기  (0) 2024.09.16
별 찍기 (점차 아래로 증가)  (0) 2024.09.16
블로그 이미지

wtdsoul

,