PTA 3.17 做题打卡

文章包含四个C++编程实例,涉及奇数偶数计数、简单算术运算、字符数组遍历以及游戏逻辑中的玩家得分判断,展示了基础编程技能的运用。
摘要由CSDN通过智能技术生成
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[1000],N,i,j=0,t=0;
    cin>>N;
    for(i=0;i<N;i++)
    {
        cin>>a[i];
        if(a[i]%2!=0)
            j++;
        else if(a[i]%2==0)
            t++;
    }
    cout<<j<<' '<<t<<endl;
        return 0;
}

L1-022奇偶分家 代码

#include<bits/stdc++.h>

using namespace std;
int main()
{
    int a,b,c;
    cin>>a;
    if(a<6)
        cout<<a+2<<endl;
    else 
        cout<<a-7+2<<endl;
    return 0;
}

L1-024 后天

#include<iostream>
#include<algorithm>

using namespace std;
int main()
{
    char a[]={"I Love GPLT"};
    int i;
    for(i=0;i<11;i++)
    cout<<a[i]<<endl;
    return 0;
}

L-026 I Love GPLT

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,i,j,t,p=0,q=0,x,y;
    cin>>A>>B;
    cin>>t;
    int turns[t][4];
    for(i=0;i<t;i++)
        for(j=0;j<4;j++)
            cin>>turns[i][j];
    for(i=0;i<t;i++)
    {
        if(turns[i][0]+turns[i][2]==turns[i][1]&&turns[i][1]==turns[i][3])
            continue;
        if(turns[i][0]+turns[i][2]==turns[i][1])
        {
            A--;
            p++;
        }
            
        else if(turns[i][0]+turns[i][2]==turns[i][3])
        {
            B--;
            q++;
        }
        
        if(A<0&&B>=0)
        {
            printf("A\n%d",q);
            break;
        }
        else if(B<0&&A>=0)
        {
            printf("B\n%d",p);
            break;
        }
    }
    return 0;
}

L1-019 谁先倒

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值