超级nice
2024-01-10 19:22:23
发布于:广东
2阅读
0回复
0点赞
#include <iostream>
#include <vector>
using namespace std;
struct Point{
int x, y;
};
int cmp(Point p1, Point p2){
return p1.x * p2.y - p2.x * p1.y;
}
int main(){
int num_tests;
cin >> num_tests;
for(int i = 0; i < num_tests; i++){
Point p0 = {0, 0};
int sum = 0;
string direction;
cin >> direction;
for(char d : direction){
Point p1;
if(d == 'N'){
p1 = {p0.x, p0.y + 1};
}else if(d == 'E'){
p1 = {p0.x + 1, p0.y};
}else if(d == 'S'){
p1 = {p0.x, p0.y - 1};
}else{
p1 = {p0.x - 1, p0.y};
}
sum += cmp(p1, p0);
p0 = p1;
}
if(sum > 0){
cout << "CW" << endl;
}else{
cout << "CCW" << endl;
}
}
return 0;
}
这里空空如也
有帮助,赞一个