Reprinted please indicate the source: http://blog.csdn.net/u012860063
Question link: http://uva.onlinejudge.org/index.php? Option = com_onlinejudge & Itemid = 8 & page = show_problem & problem = 4452
Question: two points are given to form a straight line. If you want to output any two points, the two points must form a straight line and the given straight line is vertical (note that the output points cannot have negative numbers );
The Code is as follows:
# Include <cstdio> int main () {int N, x1, x2, Y1, Y2; int CAS = 0; while (~ Scanf ("% d", & N) {While (n --) {scanf ("% d", & X1, & Y1, & X2, & Y2); printf ("case % d:", ++ CAS); If (x1 = x2) {printf ("0 0 1 0 \ n "); continue;} If (Y1 = Y2) {printf ("0 0 0 1 \ n"); continue;} If (x1-x2> 0 & y1-y2> 0) {printf ("% d 0 0% d \ n", y1-y2, x1-x2);} else if (x1-x2> 0 & y1-y2 <0) {printf ("0 0% d % d \ n", y2-y1, x1-x2);} else if (x1-x2 <0 & y1-y2> 0) {printf ("0 0% d % d \ n", y1-y2, x2-x1);} else if (x1-x2 <0 & y1-y2 <0) {printf ("% d 0 0% d \ n", y2-y1, x2-x1) ;}} return 0 ;}