C++入门同步记录#7

#include<iostream>
using namespace std;
int main() {
    int yyyy, mm;
    cin >> yyyy >> mm;
    switch (mm) {
        case 1: case 3: case 5: case 7: case 8: case 10 : case 12:
            cout << 31 << endl; break;
        case 4: case 6: case 9: case 11:
            cout << 30 << endl; break;
        case 2:
        if (!(yyyy % 400) || !(yyyy % 4) && (yyyy % 100))
            cout << 29 << endl;
        else
            cout << 28 << endl;
        break;
    default: break;
    }
    return 0;
}



#include<iostream>
using namespace std;
int main() {
    int t1, t2, maxtime = 8, maxday = 0;
    cin >> t1 >> t2;
    if (t1 + t2 > maxtime) maxtime = t1 + t2, maxday = 1;
    cin >> t1 >> t2;
    if (t1 + t2 > maxtime) maxtime = t1 + t2, maxday = 2;
    cin >> t1 >> t2;
    if (t1 + t2 > maxtime) maxtime = t1 + t2, maxday = 3;
    cin >> t1 >> t2;
    if (t1 + t2 > maxtime) maxtime = t1 + t2, maxday = 4;
    cin >> t1 >> t2;
    if (t1 + t2 > maxtime) maxtime = t1 + t2, maxday = 5;
    cin >> t1 >> t2;
    if (t1 + t2 > maxtime) maxtime = t1 + t2, maxday = 6;
    cin >> t1 >> t2;
    if (t1 + t2 > maxtime) maxtime = t1 + t2, maxday = 7;
    cout << maxday << endl;
    return 0;
}



#include<iostream>
#include<cmath>
using namespace std;
int main() {
    int n, p1, p2, p3, t1, t2, t3, total; float n1, n2, n3;
    cin >> n >> n1 >> n2 >> n3 >> p1 >> p2 >> p3;
    t1 = ceil(n / n1) * p1; 
    t2 = ceil(n / n2) * p2; 
    t3 = ceil(n / n3) * p3;
    total = t1;
    if (t2 < total) total = t2;
    if (t3 < total) total = t3;
    cout << total << endl;
    return 0;
}



#include<iostream>
using namespace std;
int main() {
    int L, i; cin >> L;
    for (i = 1; i <= L; i++) {
        cout << "Today I ate " << i << " apple";
        if (i != 1) cout << 's';
        cout << "." << endl;
    }
    return 0;
}



#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n, max_, tmp;
    cin >> n;
    cin >> max_;
    for (int i = 1; i < n; i++) {
        cin >> tmp;
        tmp = max(tmp, max_);
    }
    cout << max_ << endl;
    return 0;
}



#include<cstdio>
using namespace std;
int main() {
    int n, k, A_sum = 0, B_sum = 0;
    scanf("%d%d", &n, &k);
    for (int i = k; i <= n; i += k) 
        A_sum += i;
    B_sum = (1 + n) * n / 2 - A_sum;
    printf("%.1f ", double(A_sum) / (n / k));
    printf("%.1f", double(B_sum) / (n - n / k));
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值