精弘网络暑期 C++ 考核赛

时间:2021-09-17
本文章向大家介绍精弘网络暑期 C++ 考核赛,主要包括精弘网络暑期 C++ 考核赛使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

被打爆了

A.Jinghong Union

转义一下就好

#include<bits/stdc++.h>
using namespace std;
int main() {
    cout << "\"" << "Welcome to Jinghong Union." << "\"";
    return 0;
}

B.i18n and l10n

#include<bits/stdc++.h>
using namespace std;

char s[200];

int main() {
    cin >> s;
    int len = strlen(s);
    cout << s[0] << len - 2 << s[len - 1];
    return 0;
}

C.Digits

#include<bits/stdc++.h>
using namespace std;

int n;

int f(int x) {
    int cnt = 0;
    while(x != 0) {
	cnt += x % 10;
	x = x / 10;		
    }
    return cnt;
}

int main() {
    cin >> n;
    if(n % f(n) == 0) cout << "Yes";
    else cout << "No";
    return 0;
}

D.Sum

#include<bits/stdc++.h>
using namespace std;

int k, s, ans;

int main() {
    cin >> k >> s;
    for(int i = 0; i <= k; i++)
	for(int j = 0; j <= k; j++)
	    if(i + j <= s && i + j + k >= s) ans++;
    cout << ans;
    return 0;
}

原文地址:https://www.cnblogs.com/q1nghuan/p/15305219.html