LoginSignup
0
0

More than 3 years have passed since last update.

AtCorderテクニック備忘録

Last updated at Posted at 2020-08-17

概要

競プロ初心者の備忘録です。
何か間違いなどありましたらご教授願います。
随時更新していきます。

文字列

文字列から数値に変換(1文字ver)<2020/08/17>

char型からint型への変換

char_int
#include <iostream>
using namespace std;

int main(void){
    char a;
    int num = a - '0';
    //aはstring型だとエラーになるので注意、必ずchar型であることを確認すること
    return 0;
}

整数

切り上げ<2020/08/19>

#include<bits/stdc++.h>
using namespace std;

int main(){
  int a, b; cin >> a >> b;
  int x = ((a + b) + 2 - 1) / 2;  //切り上げ処理
  //公式:((割られる数) + (割る数) ー 1) / (割る数)  
  cout << x << endl;
}  
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