Обновить main.cpp
This commit is contained in:
35
main.cpp
35
main.cpp
@@ -89,36 +89,7 @@ void z3() {
|
||||
// Закрытие файла после чтения
|
||||
infile.close();
|
||||
}
|
||||
|
||||
void z4() {
|
||||
string path = "z4.txt";
|
||||
ofstream fout;
|
||||
string inputString;
|
||||
cout << "Введите строку: ";
|
||||
cin >> inputString;
|
||||
|
||||
fout.open(path);
|
||||
fout << inputString << endl;
|
||||
fout.close();
|
||||
|
||||
ifstream file(path);
|
||||
cout << file.rdbuf() << endl;
|
||||
|
||||
file.clear();
|
||||
string s;
|
||||
char ch;
|
||||
while (file.get(ch)) {
|
||||
if (isdigit(ch)) {
|
||||
s += ch;
|
||||
} else if (!s.empty() && s.back() != ' ') {
|
||||
s += ' ';
|
||||
}
|
||||
}
|
||||
|
||||
cout << s << endl;
|
||||
file.close();
|
||||
}
|
||||
|
||||
// Задание 4 в отдельном файле
|
||||
void sorting(string& s) {
|
||||
int n = s.length();
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
@@ -147,7 +118,6 @@ int main() {
|
||||
cout << "1. Расчет ежемесячных платежей" << endl;
|
||||
cout << "2. Поиск процента по ежемесячным платежам" << endl;
|
||||
cout << "3. Работа с файлами (запись и чтение)" << endl;
|
||||
cout << "4. Работа с числами в строке" << endl;
|
||||
cout << "5. Сортировка строки" << endl;
|
||||
cout << "0. Выход" << endl;
|
||||
cin >> choice;
|
||||
@@ -162,9 +132,6 @@ int main() {
|
||||
case 3:
|
||||
z3();
|
||||
break;
|
||||
case 4:
|
||||
z4();
|
||||
break;
|
||||
case 5:
|
||||
z5();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user