寝癖頭の解法

学習中の覚え書きを投稿、更新していきます。

AtCoder Problems in C, C++ #A - 長方形

AtCoder Beginner Contest(ABC)の過去問から、その提出コードの解答例です。
AtCoderとは、コンテストを通じて、プログラミングやアルゴリズムを学習するサービスです。
atcoder.jp
プログラミングコンテストとは、「与えられた問題をいかに素早く、正確に」解くことができるかを競うものです。
競技プログラミング」を略して、「競プロ」などと呼ばれています。

#A - 長方形
atcoder.jp

僕が作成、提出したコードは、以下のとおりです。

/*
AtCoder Problems in C
#A - 長方形
https://atcoder.jp/contests/abc027/tasks/abc027_a
提出コードの解答例
https://neguse-atama.hatenablog.com
*/
#include<stdio.h>
int main(void){
  int l1,l2,l3;
  scanf("%d %d %d",&l1,&l2,&l3);
  if(l1==l2){
    printf("%d",l3);
  }else if(l2==l3){
    printf("%d",l1);
  }else if(l3==l1){
    printf("%d",l2);
  }
  putchar('\n');
  return 0;
}
/*
AtCoder Problems in C++
#A - 長方形
https://atcoder.jp/contests/abc027/tasks/abc027_a
提出コードの解答例
https://neguse-atama.hatenablog.com
*/
#include<stdio.h>
int main(void){
  int l1,l2,l3;
  scanf("%d %d %d",&l1,&l2,&l3);
  if(l1==l2){
    printf("%d",l3);
  }else if(l2==l3){
    printf("%d",l1);
  }else if(l3==l1){
    printf("%d",l2);
  }
  putchar('\n');
  return 0;
}

AtCoder Beginner Contest(ABC)は、オンラインジャッジによるプログラミングコンテストです。
日本語と英語に対応していて、週末ごとに実施されているみたいです。
https://practice.contest.atcoder.jp/tutorial
アカウントを登録すれば、誰でも参加できます。