2023-03-09 00:03:44 +02:00
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
int findFirstDigitIndex(string str) {
|
|
|
|
|
for (int i = 0; i < str.length(); i++) {
|
|
|
|
|
if (isdigit(str[i])) {
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
|
|
|
|
|
SetConsoleOutputCP(CP_UTF8);
|
|
|
|
|
|
|
|
|
|
string inputStr;
|
|
|
|
|
cout << "Введіть строку: ";
|
|
|
|
|
cin >> inputStr;
|
|
|
|
|
int index = findFirstDigitIndex(inputStr);
|
|
|
|
|
if (index >= 0) {
|
|
|
|
|
cout << "Індекс першої цифри в цій строчці: " << index << endl;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2023-03-11 15:05:27 +02:00
|
|
|
|
cout << "У введеній строці не знайдено жодної цифри." << endl;
|
2023-03-09 00:03:44 +02:00
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|