This commit is contained in:
Asadashino 2024-06-04 15:20:20 +08:00
parent 8369eccd77
commit 4c5639c466
1 changed files with 95 additions and 0 deletions

95
cppfile/test3.cpp Normal file
View File

@ -0,0 +1,95 @@
#include<stdio.h>
#include<math.h>
#include<string.h>
#include <iostream> // cout
#include <algorithm> // find
#include <vector> // vector
#include<string>
using namespace std;
int findsame(char ip,char com[]){
int lengt;
lengt = sizeof(com);
for (int i = 0; i<lengt; i++){
if(ip == com[i]){
return 1;
break;
}
else{
return 0;
}
}
}
int main(){
int num;
char resu[3][14];
vector<char> d1[11];
char common[11];
int *p;
int *q;
int oi = 0;
int budeng;
scanf("%d",&num);
for (int i = 0;i<num;i++){
for(int j=0;j<4;j++){
gets(resu[j]);
}
for(int k = 1;k <= 3;k++){
if (resu[k][10] == 'e'){
while(oi < 4 ){
p = find(d1->begin(),d1->end(),resu[k][oi]);
if (p !=d1->end){
continue;
}
else{
d1->push_back(resu[k][oi])
}
oi++;
}
for (int secp = 5;secp < 9;secp++){
p = find(d1->begin(),d1->end(),resu[k][secp]);
if (p !=d1->end){
continue;
}
else{
d1->push_back(resu[k][secp])
}
}
}
else{
budeng = k;
continue;
}
}
}
for (int fp = 0;fp<4;fp++){
q = find(d1->begin(),d1->end(),resu[budeng][fp]);
if (q != d1->end){
if(resu[budeng][9] == 'u'){
printf('%c is the counterfeit coin and it is light.',resu[budeng][fp]);
}
else{
printf('%c is the counterfeit coin and it is heavy.',resu[budeng][fp]);
}
break;
}
}
for (int fp1 = 5;fp1<9;fp1++){
q = find(d1->begin(),d1->end(),resu[budeng][fp1]);
if (q != d1->end){
if(resu[budeng][9] == 'u'){
printf('%c is the counterfeit coin and it is heavy.',resu[budeng][fp1]);
}
else{
printf('%c is the counterfeit coin and it is light.',resu[budeng][fp1]);
}
break;
}
}
}