HZNU短学期题解 2023-09-12

昨天拿驾照了 咕一天哈哈哈哈哈哈哈哈

1.

print("  (\____/)")
print("  / @__@ \\")
print(" (  (oo)  )")
print("  `-.~~.-'")
print("   /    \\")
print(" @/      \_")
print("(/ /    \ \)")
print(" WW`----'WW")

2.

while True:
    try:
        s=input()
        successful=False
        A_first=0
        A_sec=0
        li=[]
        for i in range(len(s)-1):
            if s[i]=='A' and s[i+1]=='B':
                l=[i,i+1]
                li.append(l)
        for i in range(len(s) - 1):
            if s[i]=='B' and s[i+1]=='A':
                for x in li:
                    if x[1]!=i and x[0]!=i+1:
                        successful = True
                        break
        if successful:
            print("yu ye sa wang dai xing")
        else:
            print("zhen shi ou ba")
    except:
        break

3. 注意为c++代码

#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int t;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while (t--)
    {
        int wwa,wwb,bma,bmb,kka,kkb;
        cin >> wwa >> wwb >> bma >> bmb >> kka >> kkb;
        double fenmu=(wwa*wwb)+(bma*bmb)+(kka*kkb);
        double fenzi=wwa+bma+kka;
        double jiaquan=fenmu/fenzi;
        printf("%.2lf\n",jiaquan);
    }
    return 0;
}

4.同上为c++

#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin >> T;
    while(T--)
    {
        int n;cin >> n;
        char name[100][30];
        char temp1[100];
        int sum[100];
        int a,b,i,j;
        for (i=0;i<n;i++)
        {
            cin >> name[i] >> a >> b;
            sum[i]=(a+b);
        }
        for (i=n-1;i>=0;i--)
        {
            for (j=0;j<i;j++)
            {
                if (sum[j]<sum[j+1])
                {
                    int temp=sum[j];
                    sum[j]=sum[j+1];
                    sum[j+1]=temp;
                    strcpy(temp1,name[j]);
                    strcpy(name[j],name[j+1]);
                    strcpy(name[j+1],temp1);
                }
            }
        }
        for (i=0;i<n;i++)
        {
            puts(name[i]);
        }
    }
    return 0;
}

5.原题有题解:https://blog.csdn.net/qq_49006646/article/details/107031160

#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    while (1)
    {
        cin >> s;
        if (s=="!") break;
        for (int i = 0; i < s.length(); ++i) {
            if(s[i]>='A'&&s[i]<='Z')
            {
                int number=((int)s[i]+3-64)%26;
                if(number==0)
                    number=26;
                printf("%c",(int)'A'+number-1);
            }
            if(s[i]>='a'&&s[i]<='z')
            {
                int number=((int)s[i]+13-96)%26;
                if(number==0)
                    number=26;
                printf("%c",(int)'a'+number-1);
            }
        }
        puts("");
    }
    return 0;
}

6.

n, m = map(int, input().split())
is_Fakenews = False
now = n
if now < 0: #注意开头要特判
    is_Fakenews = True
for i in range(m):
    s = list(input().split())
    if s[0] == 'Add':
        now += int(s[1])
    elif s[0] == 'Sub':
        now -= int(s[1])
        if now < 0:
            is_Fakenews = True
    else:
        if is_Fakenews:
            print("fake news!")
        else:
            print(now)

祝大家早日AC~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值