前往
大廳
主題

[OJ練習] 579、10079 新年快樂,我回來ㄌ

テリ君(桃夫模式) | 2023-01-03 10:34:37 | 巴幣 2 | 人氣 132

579(1/5)
這題就是,小學的時鐘角度計算,對

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

int main(){
    int H, M;
    float H_A, M_A, A; // A for angle.
    while(scanf("%d:%d", &H, &M) != EOF && (H || M)){ // if H:M = 0:00 then bye bye
        //scan the time and translate them into angle.
        //need to use float to divide or it will be int I guess.
        H_A = H * 30.0 + (M / 60.0) * 30.0;
        M_A = M * 6.0;
        A = fabs(H_A - M_A);
        printf("%.3f\n",(A > 180.0) ? 360.0 - A : A);
    }
    
    return 0;
}

10079(1/5)
阿這題就是,切披薩,(n + (n - 1) + ... + 1) + 1

#include <stdio.h>

int main(){
    int N, result;
    while(scanf("%d", &N) && (N >= 0 && N <= 210000000)){
        while(N != 0){
            result += N;
            N--;
        }
        printf("%d\n", result + 1);
        result = 0;
    }
    return 0;
}


這甚麼新年禮包嗎?
讓我再放鬆一天(?

是說下一題就是101
剛開始練習遇到的惡夢
或許可以開啟復仇計畫?
從4/5變成2/5之類的

創作回應

更多創作