求解40分
查看原帖
求解40分
822206
ton406楼主2022/11/25 00:49
#include<iostream>
#include<cstring>
#include<stdio.h>
using namespace std;
char a[10];
char s[100000];
int main() {
	cin >> a;
	getchar();
	
	cin.get(s, 10000);
	for (int i = 0; i < strlen(a); i++) {
		if (a[i] >= 'A' && a[i] <= 'Z') {
			a[i] += 32;
		}
	}
	for (int i = 0; i < strlen(s); i++) {
		if (s[i] >= 'A' && s[i] <= 'Z') {
			s[i] += 32;
		}
	}
	int ISPRIME = 0;
	int CNT = 0;
	int temp = 0;
	int isprime = 0;
	for (int o = 0; o < strlen(s); o++) {
		int cnt = 0;
		for (int i = 0,j=0; i < strlen(a); i++,j++) {

			if (a[i] == s[o + j]) {
				cnt++;
				if (cnt == strlen(a) && s[o + j + 1] == ' ') {
					CNT++;
					if (isprime == 0) {
						isprime = 1;
						temp = o;
						ISPRIME = 1;
					}
				}
			}
			else break;
		}
	}
	if (ISPRIME == 0) {
		cout << -1;
		return 0;
	}
	cout << CNT<<' ';
	cout << temp;
	

}

只有1234AC,其他WA,求大佬帮助

2022/11/25 00:49
加载中...