32 lines
702 B
C++
32 lines
702 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 << "У введеній строці не знайдено жодної цифри." << endl;
|
||
}
|
||
return 0;
|
||
}
|