32 lines
662 B
C++
32 lines
662 B
C++
#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 {
|
|
cout << "No digit was found in the input string." << endl;
|
|
}
|
|
return 0;
|
|
}
|