计蒜客普及T3/提高T1-----T1171-T1244(仅代码)--wizard

这篇博客主要分享了计蒜客中普及T3/提高T1阶段的编程题目代码,包括T1171, T1176, T1180, T1189, T1215, T1226和T1244等题目的解决方案,旨在帮助读者理解和学习C++编程技巧。" 95315680,8679377,Java控制台实现通讯录增删改查,数据库操作,"['Java', '数据库操作', '控制台开发', '增删改查功能', '通讯录应用']
摘要由CSDN通过智能技术生成

计蒜客普及T3/提高T1-----T1171-T1244(仅代码)

题目地址:T1171-T1244

首先是

T1171

在这里插入图片描述

#include <iostream>
#include <algorithm>

using namespace std;
struct people {
   
    int have = 0;
    int all[10010];
} p[101];

int main() {
   
    int n;
    cin >> n;
    int name;
    int num, temp;
    for (int i = 0; i < n; ++i) {
   //输入
        cin >> name >> num;
        for (int j = 0; j < num; ++j) {
   
            cin >> temp;
            p[temp].all[p[temp].have] = name;
            p[temp].have++;
        }
    }
    int max = 0;
    for (int i = 1; i <= 100; ++i) {
   //找最大
        if (p[i].have > p[max].have) {
   
            max = i;
        }
    }
    cout << max << endl;
    sort(p[max].all, p[max].all + p[max].have);
    for (int i = 0; i < p[max].have; ++i) {
   

        cout << p[max].all[i] << " ";
        while (p[max].all[i] == p[max].all[i + 1])i++;//去重
    }

}

T1176

#include <iostream>
#include <cstring>
using namespace std;
int num[510];//个数
char s[510],c[510][10];//字符串,分割后的字符串
int main(){
   
    int n;
    cin>>n;
    cin>>s;
    int max=0;
    int len=strlen(s);
    for (int i = 0; i < len-n+1; ++i) {
   
        for (int j = 0; j < n; ++j) {
   //分割
            c[i][j]=s[j+i];
        }
        for (int k = 0; k <= i; ++k) {
   //统计个数
            if(strcmp(c[k],c[i])==0){
   
                num[k]++;
                if(num[k]>max)max=num[k];
            }
        }

    }
    if(max==1)cout<<"NO";//输出
    else {
   
        cout<<max<<endl;
        for (int i = 0; i < len - n + 1; ++i) {
   
            if(num[i]==max)cout<<c[i]<<endl;
        }
    }
}

在这里插入图片描述

T1180

#include <string>
#include <algorithm>
#include <iostream>
#include <cstdio>
 
using namespace std;
 
const int MAXN = 250;
 
string s1,s2;
int len1,len2;
int a[MAXN],b[MAXN],c[MAXN]={
   0};
 
void add0(string &s,int &l,int &r)
{
   
    for (int i = l
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值