LoginSignup
0
0

More than 3 years have passed since last update.

C++で数字を最初から取り出す方法

Posted at

メモ代わり

意外と難しいのだと感じました.まー難しいなーという感じ.

#include<iostream>
#include<string>

int main() {
    std::string s;
    std::cin >> s;
    int n = s.length(), sur = 0;
    for (int i = 0; i < n;i++) {
        sur += int(s[i]-'0');
        sur %= 9;
    }
    if (sur == 0) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    return 0;
}

まだまだ勉強ですな(笑)

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