图片找多点最亮色
作者:
半城
,
2024-04-04 13:47:33
,
所有人可见
,
阅读 6
#include<iostream>
#include<fstream>
using namespace std;
string s;
string new_s;
string place[720][1280];
//string转int型
int to_int(string s){
int total=0,num=0;
int len=s.size();
for(int i=0;i<len;i++){
num = s[i] - '0';
for(int j=1;j<=len-i-1;j++){
num=num*10;
}
total = total+num;
}
return total;
}
int main(){
ifstream fin("in.txt"); //把in.txt文件输入重定向
//ofstream fout("out.txt");
getline(fin,s);
int len=s.size();
int start=0;
string new_s;
int x,y;
int start_x=0,start_y=0,end_x=0,end_y=0;
//cout<<s.substr(0,3);
//遍历全部坐标
for(int i=0;i<len;i++){
if(s[i]==','||s[i]==' '||s[i]=='|'){
if(s[i]==','){
new_s=s.substr(start,i-start);
start = i+1;
x = to_int(new_s);
}
else if(s[i]==' '){
new_s=s.substr(start,i-start);
start = i+1;
y = to_int(new_s);
}else if(s[i]=='|'){
new_s=s.substr(start,i-start);
start = i+1;
place[x][y] = new_s;
end_x=x;
end_y=y;
}
}
}
for(int x=0;x<720;x++){
for(int y=0;y<1280;y++){
if(place[x][y]!=""){
//cout<<x<<" "<<y<<endl;
start_x=x;
start_y=y;
x=2000;
y=2000;
}
}
}
cout<<start_x<<" "<<start_y<<" "<<end_x<<" "<<end_y;
}