LoginSignup
0
1

More than 3 years have passed since last update.

4桁の整数の各桁の値を取り出す(C++)

Last updated at Posted at 2021-02-25

AtCoder用備忘録

例えばx=1234を受け取って、以下のように各桁の値a=1、b=2、c=3、d=4を格納できます

main.cpp
    int x; cin >>x;
    //各桁の値をa,b,c,dとする
    int a=x/1000;
    int b=(x/100)%10;
    int c=(x/10)%10;
    int d=x%10;

参考問題
abc079 C - Train Ticket

0
1
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
1