answer (Верно ли, что введённое число состоит из одинаковых цифр)

#include "stdafx.h"//del #include <iostream> #include <string> using namespace std; int main() { string str; while (true) { cout << "Enter the number: "; cin >> str; int count = 0; int first = str[0] - '0'; for (int i = 0; i < (str.size()); i++) { if ((str[i] < '0') || (str[i] > '9')) { cout << "Not a number"; exit(1); } if (first == (str[i] - '0')) count++; } if (count == str.size()) cout << "YES! (: " <<endl <<endl; else cout << "NO! ): " <<endl <<endl; } return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.