結果

問題 No.571 3人兄弟(その2)
ユーザー extelo
提出日時 2017-11-21 19:00:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 28,288 KB
最終ジャッジ日時 2025-01-05 04:17:00
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |   scanf("%d %d", &a[0].height, &a[0].weight);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:17:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |   scanf("%d %d", &a[1].height, &a[1].weight);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:18:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |   scanf("%d %d", &a[2].height, &a[2].weight);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

class inf
{
public:
  int height;
  int weight;
  char name;
};

int main(void)
{


  inf a[3];
  scanf("%d %d", &a[0].height, &a[0].weight);
  scanf("%d %d", &a[1].height, &a[1].weight);
  scanf("%d %d", &a[2].height, &a[2].weight);
  a[0].name = 'A';
  a[1].name = 'B';
  a[2].name = 'C';

  for(int i=0; i<3; i++){
    for(int j=i+1; j<3; j++){
      if(a[i].height<a[j].height){
        inf temp = a[j];
        a[j] = a[i];
        a[i] = temp;
      } else if(a[i].height==a[j].height && a[i].weight>a[j].weight){
        inf temp = a[j];
        a[j] = a[i];
        a[i] = temp;
      }
    }
  }

  for(int i=0;i<3;i++){
    printf("%c\n", a[i].name);
  }
  return 0;

}
0