게임강의
각종 노하우 분류

[C를 활용한 문제해결 기법의 근간] 학습용!! fraction

컨텐츠 정보

본문

#define _CRE_SECURE_NO_WARNINGS
#pragma warning(disable:4996)
#include <stdio.h>
int main() {
    FILE *input_file = fopen("fraction.inp", "r");
    FILE *output_file = fopen("fraction.out", "w");
    int k = 0;
    int x = 0;
    int y = 0;
    int count = 0;
    int xy = 0;
    int yx = 0;
    int result = 0;
    int q = 1;
    while (q==1) {
        x = 0, y = 0, xy = 0, yx = 0, count = 0;
        fscanf(input_file,"%d", &k);
        for (x = k; x <= 2 * k; x++) {
            if (k == 0) {
                q = 0;
                break;
            }
            xy = k*x;
            yx = x - k;
            if (x == k) {
                continue;
            }
            else {
                result = xy%yx;
            }
            if (result == 0) {
                count++;
                continue;
            }
            else {
                continue;
            }
            if (yx == 1) {
                count++;
                continue;
            }
            else {
                continue;
            }
        }
        if(count==0){
            break;
        }
        else {
            fprintf(output_file,"%d\n", count);
        }
    }
}

관련자료

댓글 0
등록된 댓글이 없습니다.
각종 노하우 87 / 1 페이지
번호
제목
이름

강의실

🏆 포인트 랭킹 TOP 10
순위 닉네임 포인트
1 no_profile 타키야겐지쪽지보내기 자기소개 아이디로 검색 전체게시물 147,509
2 no_profile 보거스쪽지보내기 자기소개 아이디로 검색 전체게시물 92,332
3 no_profile 검은고양이쪽지보내기 자기소개 아이디로 검색 전체게시물 69,383
4 서번트쪽지보내기 자기소개 아이디로 검색 전체게시물 57,810
5 no_profile 불멸의행복쪽지보내기 자기소개 아이디로 검색 전체게시물 57,281
6 no_profile 동가리쪽지보내기 자기소개 아이디로 검색 전체게시물 56,810
7 no_profile 라프텔쪽지보내기 자기소개 아이디로 검색 전체게시물 52,661
8 no_profile Gatchaman쪽지보내기 자기소개 아이디로 검색 전체게시물 47,885
9 no_profile 닥터스쪽지보내기 자기소개 아이디로 검색 전체게시물 35,440
10 no_profile 냥집사쪽지보내기 자기소개 아이디로 검색 전체게시물 30,398
알림 0