Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
770 B
1
Indexable
Never
#include <stdio.h>

int main() {
    float NG, CongSuat;
    int soThang;
    printf("Nhap NG: ");
    scanf("%f", &NG);
    printf("Nhap Cong Suat: ");
    scanf("%f", &CongSuat);
    printf("Nhap so thang: ");
    scanf("%d", &soThang);
    int n = soThang;
    float SL[n];
    
    for(int i = 0; i < n; i++) {
        printf("Nhap SL thang thu %d: ", i+1);
        scanf("%f", &SL[i]);
    }
    
    float Tong = 0;
    float KH_1SP = NG/CongSuat;
    float KH[n];
    
    for(int i = 0; i < n; i++) {
        KH[i] = SL[i] * KH_1SP;
        Tong = Tong + KH[i];
    }
    
    // In ra KH
    for(int i = 0; i < n; i++) {
        printf("%.2f  ", KH[i]);
    }
    
    printf("\nTong: %.2f", Tong);
    
    while(1==1){ printf("\nCiu tui"); };

    return 0;
}
Leave a Comment