0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AtCoder自分用まとめ007(ABC196A Difference Max

Posted at

概要

自分のために、AtCoderで身に付けた内容・コードをまとめておく。

内容

整数 a,b,c,d が与えられます。
a≤x≤b, c≤y≤d となるように整数 x,y を選ぶとき、 x−y の最大値を求めてください。

入力形式
a b
c d

C

# include<stdio.h>
int main() {
  int a,b,c,d;
  scanf("%d%d%d%d", &a,&b,&c,&d);

  printf("%d\n", (((b>a)?b:a)-((d>c)?c:d)));
  return 0;
}

C++

# include<iostream>
using namespace std;
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  cout<<max(a, b)-min(c, d)<<endl;
}

C++<bits/stdc++.h>

# include<bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  cout<<max(a, b)-min(c, d)<<endl;
}

Python3

a, b = map(int, input().split())
c, d = map(int, input().split())

print(max(a, b)-min(c, d))

Haskell

編集中

Racket

# lang racket
(define a (read))
(define b (read))
(define c (read))
(define d (read))
(display (- (max a b) (min c d)))
(newline)

Vim

編集中

参考にさせていただいたページ

感想

もう少し慣れたら書き直したい。。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?