Two Points Revisited
向量旋转90度
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
struct Point{
int x, y;
};
void Swap(Point& t1, Point& t2) {
int temp = t1.x;
t1.x = t2.x;
t2.x = temp;
temp = t1.y;
t1.y = t2.y;
t2.y = temp;
}
int main(){
int s, tt, cases = 0;
Point a1, b1, a2, b2;
scanf("%d", &tt);
while(tt--){
cases++;
scanf("%d %d %d %d", &a1.x, &a1.y, &a2.x, &a2.y);
if (a1.x > a2.x) swap(a1,a2);
int dy = abs(a1.y-a2.y);
int dx = abs(a1.x-a2.x);
b1.x = 0;
b2.x = dy;
if(a1.y < a2.y) {
b1.y = dx;
b2.y = 0;
} else {
b1.y = 0;
b2.y = dx;
}
printf("Case %d: %d %d %d %d\n", cases, b1.x, b1.y, b2.x, b2.y);
}
}