結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2017-05-11 01:56:11 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 931 bytes |
コンパイル時間 | 119 ms |
コンパイル使用メモリ | 24,320 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-15 07:14:44 |
合計ジャッジ時間 | 1,040 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:42:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 42 | scanf("%d%d", &p[i].x, &p[i].y); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio>class pos_t{public:int x, y;bool operator==(pos_t& rhs){return (x==rhs.x && y==rhs.y);}pos_t operator+(pos_t& rhs){pos_t ret;ret.x=x+rhs.x;ret.y=y+rhs.y;return ret;}pos_t operator-(pos_t& rhs){pos_t ret;ret.x=x-rhs.x;ret.y=y-rhs.y;return ret;}void print(void){printf("%d %d\n", x, y);}};int main(void){pos_t p[2], o, a, b;int i;while(scanf("%d%d", &o.x, &o.y)==2){for(i=0;i<2;i++){scanf("%d%d", &p[i].x, &p[i].y);p[i]=p[i]-o;}a=p[0];b=p[1];if((a.x==b.y && a.y==-b.x) || (a.x==-b.y && a.y==b.x)){(a+b+o).print();continue;}a=p[0]-p[1];b=p[1];if((a.x==b.y && a.y==-b.x) || (a.x==-b.y && a.y==b.x)){(a+o).print();continue;}a=p[1]-p[0];b=p[0];if((a.x==b.y && a.y==-b.x) || (a.x==-b.y && a.y==b.x)){(a+o).print();continue;}printf("-1\n");}return 0;}