|
0 / 0 / 0
Регистрация: 10.03.2023
Сообщений: 2
|
|
Слишком мало аргументов в вызове функции10.03.2023, 21:22. Показов 983. Ответов 9
#include <iostream>
#include <fstream> #include <string> #include <vector> #include <algorithm> using namespace std; struct Subscriber { string name; string phoneNumber; string address; }; vector<Subscriber> directory; void addSubscriber() { Subscriber newSubscriber; cout << "Enter the name of the subscriber: "; getline(cin, newSubscriber.name); cout << "Enter the phone number: "; getline(cin, newSubscriber.phoneNumber); cout << "Enter the address (house number and street name): "; getline(cin, newSubscriber.address); // Check if the subscriber already exists in the directory bool subscriberExists = false; for (const auto& subscriber : directory) { if (subscriber.name == newSubscriber.name) { subscriberExists = true; break; } } if (subscriberExists) { cout << "Subscriber already exists in the directory." << endl; } else { directory.push_back(newSubscriber); cout << "Subscriber added to the directory." << endl; } } void updateSubscriber() { string nameToUpdate; cout << "Enter the name of the subscriber to update: "; getline(cin, nameToUpdate); // Find the subscriber in the directory bool subscriberFound = false; for (auto& subscriber : directory) { if (subscriber.name == nameToUpdate) { subscriberFound = true; cout << "Enter the new phone number: "; getline(cin, subscriber.phoneNumber); cout << "Enter the new address (house number and street name): "; getline(cin, subscriber.address); cout << "Subscriber information updated." << endl; break; } } if (!subscriberFound) { cout << "Subscriber not found in the directory." << endl; } } void deleteSubscriber() { string nameToDelete; cout << "Enter the name of the subscriber to delete: "; getline(cin, nameToDelete); // Find the subscriber in the directory bool subscriberFound = false; for (auto it = directory.begin(); it != directory.end(); ++it) { if (it->name == nameToDelete) { subscriberFound = true; cout << "Are you sure you want to delete " << it->name << " from the directory? (Y/N): "; string confirmation; getline(cin, confirmation); if (confirmation == "Y" || confirmation == "y") { directory.erase(it); cout << "Subscriber deleted from the directory." << endl; } else { cout << "Deletion canceled." << endl; } break; } } if (!subscriberFound) { cout << "Subscriber not found in the directory." << endl; } } void displaySubscriber(const Subscriber& subscriber) { cout << "Name: " << subscriber.name << endl; cout << "Phone Number: " << subscriber.phoneNumber << endl; cout << "Address: " << subscriber.address << endl; cout << endl; } void displayDirectory() { if (directory.empty()) { cout << "Directory is empty." << endl; } else { sort(directory.begin(), directory.end(), [](const Subscriber& s1, const Subscriber& s2) { return s1.name < s2.name; }); for (const auto& subscriber : directory) { displaySubscriber(subscriber); } } } void searchByName() { string nameToSearch; cout << "Enter the name of the subscriber to search: "; getline(cin, nameToSearch); bool subscriberFound = false; for (const auto& subscriber : directory) { if (subscriber.name == nameToSearch) { subscriberFound = true; displaySubscriber(subscriber); } } if (!subscriberFound) { cout << "Subscriber not found in the directory." << endl; } } void saveDirectory() { ofstream outputFile("directory.txt"); if (outputFile.is_open()) { for (const auto& subscriber : directory) { outputFile << subscriber.name << "," << subscriber.phoneNumber << "," << subscriber.address << endl; } cout << "Directory saved to file." << endl; } else { cout << "Failed to open file for writing." << endl; } outputFile.close(); } void loadDirectory() { ifstream inputFile("directory.txt"); if (inputFile.is_open()) { directory.clear(); string line; while (getline(inputFile, line)) { Subscriber subscriber; size_t commaIndex = line.find(","); subscriber.name = line.substr(0, commaIndex); line.erase(0, commaIndex + 1); commaIndex = line.find(","); subscriber.phoneNumber = line.substr(0, commaIndex); line.erase(0, commaIndex + 1); subscriber.address = line; directory.push_back(subscriber); } cout << "Directory loaded from file." << endl; } else { cout << "Failed to open file for reading." << endl; } inputFile.close(); } int main() { char choice; do { cout << "A - Add a subscriber" << endl; cout << "U - Update a subscriber" << endl; cout << "D - Delete a subscriber" << endl; cout << "S - Search for a subscriber by name" << endl; cout << "L - List all subscribers" << endl; cout << "V - View subscriber card" << endl; cout << "X - Save and exit" << endl; cout << "Please enter your choice: "; cin >> choice; cin.ignore(); // Ignore the newline character left in the input buffer switch (choice) { case 'A': case 'a': addSubscriber(); break; case 'U': case 'u': updateSubscriber(); break; case 'D': case 'd': deleteSubscriber(); break; case 'S': case 's': searchByName(); break; case 'L': case 'l': displayDirectory(); break; case 'V': case 'v': displaySubscriber(); break; case 'X': case 'x': saveDirectory(); break; default: cout << "Invalid choice. Please try again." << endl; break; } } while (choice != 'X' && choice != 'x'); return 0; } 207 строка показывает не понимаю че делать
0
|
|
| 10.03.2023, 21:22 | |
|
Ответы с готовыми решениями:
9
Слишком мало аргументов в вызове функции Слишком мало аргументов в вызове функции
|
|
Лежебока
|
|||||||||
| 10.03.2023, 21:52 | |||||||||
|
Но так:
Имя функции и ее принимаемые параметры
0
|
|||||||||
|
4086 / 2975 / 813
Регистрация: 29.06.2020
Сообщений: 11,000
|
|
| 10.03.2023, 21:55 | |
|
0
|
|
|
Вездепух
12942 / 6809 / 1821
Регистрация: 18.10.2014
Сообщений: 17,234
|
|
| 10.03.2023, 22:04 | |
|
0
|
|
|
Лежебока
|
|||||||||||||
| 10.03.2023, 22:30 | |||||||||||||
|
Добавлено через 4 минуты
0
|
|||||||||||||
|
4086 / 2975 / 813
Регистрация: 29.06.2020
Сообщений: 11,000
|
|
| 10.03.2023, 22:44 | |
|
0
|
|
|
4086 / 2975 / 813
Регистрация: 29.06.2020
Сообщений: 11,000
|
||||||||
| 10.03.2023, 22:52 | ||||||||
|
Карточку какого подписчика/абонента он хочет увидеть. Наверное его спросить нужно. Добавлено через 1 минуту void displayDirectory()Добавлено через 53 секунды
0
|
||||||||
|
4086 / 2975 / 813
Регистрация: 29.06.2020
Сообщений: 11,000
|
|||
| 10.03.2023, 23:02 | |||
|
Если включить бабу Вангу : - смотрим сколько "подписчиков" в "папке" - спрашиваем п\н подписчика для показа. - отображаем его
0
|
|||
| 10.03.2023, 23:02 | |
|
Помогаю со студенческими работами здесь
10
Слишком мало аргументов в вызове функции Ошибка слишком мало аргументов в вызове функции Ошибка. Слишком мало аргументов в вызове функции Слишком мало аргументов в функции Мало аргументов в вызове функции? Искать еще темы с ответами Или воспользуйтесь поиском по форуму: |
|
Новые блоги и статьи
|
|||
|
Как дизайн сайта влияет на конверсию: 7 решений, которые реально повышают заявки
Neotwalker 08.03.2026
Многие до сих пор воспринимают дизайн сайта как “красивую оболочку”. На практике всё иначе: дизайн напрямую влияет на то, оставит человек заявку или уйдёт через несколько секунд.
Даже если у вас. . .
|
Модульная разработка через nuget packages
DevAlt 07.03.2026
Сложившийся в . Net-среде способ разработки чаще всего предполагает
монорепозиторий в котором находятся все исходники.
При создании нового решения, мы просто добавляем нужные проекты
и имеем. . .
|
Модульный подход на примере F#
DevAlt 06.03.2026
В блоге дяди Боба наткнулся на такое определение:
В этой книге («Подход, основанный на вариантах использования») Ивар утверждает,
что архитектура программного обеспечения — это
структуры,. . .
|
Управление камерой с помощью скрипта OrbitControls.js на Three.js: Вращение, зум и панорамирование
8Observer8 05.03.2026
Содержание блога
Финальная демка в браузере работает на Desktop и мобильных браузерах. Итоговый код: orbit-controls-threejs-js. zip. Сканируйте QR-код на мобильном. Вращайте камеру одним пальцем,. . .
|
|
SDL3 для Web (WebAssembly): Синхронизация спрайтов SDL3 и тел Box2D
8Observer8 04.03.2026
Содержание блога
Финальная демка в браузере. Итоговый код: finish-sync-physics-sprites-sdl3-c. zip
На первой гифке отладочные линии отключены, а на второй включены:. . .
|
SDL3 для Web (WebAssembly): Идентификация объектов на Box2D v3 - использование userData и событий коллизий
8Observer8 02.03.2026
Содержание блога
Финальная демка в браузере. Итоговый код: finish-collision-events-sdl3-c. zip Сканируйте QR-код на мобильном и вы увидите, что появится джойстик для управления главным героем.
. . .
|
Реалии
Hrethgir 01.03.2026
Нет, я не закончил до сих пор симулятор. Эта задача сложнее. Не получилось уйти в плавсостав, но оно и к лучшему, возможно. Точнее получалось - но сварщиком в палубную команду, а это значит, в моём. . .
|
Ритм жизни
kumehtar 27.02.2026
Иногда приходится жить в ритме, где дел становится всё больше, а вовлечения в происходящее — всё меньше. Плотный график не даёт вниманию закрепиться ни на одном событии. Утро начинается с быстрых,. . .
|