{
}
Online Python Compiler
Online R Compiler
Online SQL Editor
Online HTML/CSS Editor
Online Java Compiler
Online C Compiler
Online C++ Compiler
Online C# Compiler
Online JavaScript Compiler
Online Typescript Compiler
Online GoLang Compiler
Online Rust Compiler
Scala Online Compiler
Dart Online Compiler
Ruby Online Compiler
Online PHP Compiler
Online Swift Compiler
Generating Link
Generating Link
Share your code
Share code
Copy Link
Copied to clipboard
or share using
Build your resume with HTML & CSS and win $100
Get featured on Programiz PRO and the Wall of Inspiration.
Build your resume with HTML & CSS and win $100
Join Challenge →
Join Challenge →
Build your resume with HTML & CSS and win $100
Get featured on Programiz PRO and the Wall of Inspiration.
Build your resume with HTML & CSS and win $100
Join Challenge →
Join Challenge →
C++ Online Compiler
Learn Python App
Learn Python
main.cpp
Output
main.cpp
Share
Run
Run
#include <iostream> #include <string> #include <cstring> using namespace std; class TodoList { private: static const int MAX_TASKS = 100; string tasks[MAX_TASKS]; int taskCount; public: TodoList() : taskCount(0) {} void addTask(const string& task) { if (taskCount < MAX_TASKS) { tasks[taskCount] = task; taskCount++; cout << "Задачата е добавена успешно!\n"; } else { cout << "Списъкът е пълен!\n"; } } void removeTask(int index) { if (index >= 0 && index < taskCount) { for (int i = index; i < taskCount - 1; i++) { tasks[i] = tasks[i + 1]; } taskCount--; cout << "Задачата е премахната успешно!\n"; } else { cout << "Невалиден номер на задача!\n"; } } void displayTasks() { if (taskCount == 0) { cout << "Списъкът е празен!\n"; return; } cout << "Списък с задачи:\n"; for (int i = 0; i < taskCount; ++i) { cout << i << ". " << tasks[i] << "\n"; } } }; int main() { TodoList todoList; int choice; string task; while (true) { cout << "\n--- Управление на задачи ---\n"; cout << "1. Добавяне на задача\n"; cout << "2. Премахване на задача\n"; cout << "3. Показване на задачи\n"; cout << "4. Изход\n"; cout << "Въведете избор: "; cin >> choice; switch (choice) { case 1: cin.ignore(); cout << "Въведете задача: "; getline(cin, task); todoList.addTask(task); break; case 2: int index; cout << "Въведете номер на задача за премахване: "; cin >> index; todoList.removeTask(index); break; case 3: todoList.displayTasks(); break; case 4: cout << "Довиждане!\n"; return 0; default: cout << "Невалиден избор. Опитайте отново.\n"; } } return 0; }
Output
Clear