Compare commits

...

2 Commits
main ... master

Author SHA1 Message Date
Asadashino 4c5639c466 changed 2024-06-04 15:20:20 +08:00
Asadashino 8369eccd77 tst1ed 2024-03-05 11:06:17 +08:00
2 changed files with 121 additions and 0 deletions

26
c_cpp/fileio.py Normal file
View File

@ -0,0 +1,26 @@
from typing import List
class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
intervals.sort()
outp = []
inlen =len(intervals)
curli = intervals[0]
if inlen == 1:
return intervals
else:
for i in range(1,inlen):
if intervals[i][0] > curli[1]:
outp.append(curli)
curli = intervals[i]
continue
else:
if intervals[i][1] >curli[1]:
curli[1] = intervals[i][1]
outp.append(curli)
outp.sort()
return outp

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;
}
}
}