diff --git a/Lesson_2/.gitignore b/Lesson_2/.gitignore new file mode 100644 index 0000000..5de729e --- /dev/null +++ b/Lesson_2/.gitignore @@ -0,0 +1 @@ +*.pro \ No newline at end of file diff --git a/Lesson_2/Task_1/.gitignore b/Lesson_2/Task_1/.gitignore new file mode 100644 index 0000000..4a0b530 --- /dev/null +++ b/Lesson_2/Task_1/.gitignore @@ -0,0 +1,74 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* +CMakeLists.txt.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/Lesson_2/Task_1/main.cpp b/Lesson_2/Task_1/main.cpp new file mode 100644 index 0000000..553edde --- /dev/null +++ b/Lesson_2/Task_1/main.cpp @@ -0,0 +1,48 @@ +#include + +using namespace std; + +int main() +{ + int accounts[10]; + + for (int account = 0; account < 10; ++account) + accounts[account] = 0; + + while (true) { + int action = 0; + + cout << "Enter action (1 - add money, 2 - remove money, 3 - display all balances): "; + cin >> action; + + if (action == 1 || action == 2) { + int number = 0; + int money = 0; + cout << "Enter account number: "; + cin >> number; + if (number >= 0 && number < 10) { + cout << "Enter the amount of money: "; + cin >> money; + if (money > 0) { + if (action == 1) { + accounts[number] += money; + cout << "Money added." << endl; + } else if (accounts[number] >= money) { + accounts[number] -= money; + cout << "Money removed." << endl; + } else + cout << "Not enough money." << endl; + } else + cout << "The amount must be positive." << endl; + } else + cout << "Invalid account number." << endl; + } else if (action == 3) { + for (int account = 0; account < 10; ++account) + cout << "Account " << account << ": " << accounts[account] << endl; + } else + cout << "Invalid action." << endl; + } + + + return 0; +} diff --git a/Lesson_2/Task_2/.gitignore b/Lesson_2/Task_2/.gitignore new file mode 100644 index 0000000..4a0b530 --- /dev/null +++ b/Lesson_2/Task_2/.gitignore @@ -0,0 +1,74 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* +CMakeLists.txt.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/Lesson_2/Task_2/main.cpp b/Lesson_2/Task_2/main.cpp new file mode 100644 index 0000000..57dc354 --- /dev/null +++ b/Lesson_2/Task_2/main.cpp @@ -0,0 +1,29 @@ +#include + +using namespace std; + +int main() +{ + int numbers[20]; + int maximum = 0; + for (int number = 0; number < 20; ++number) { + cout << "Enter value: "; + cin >> numbers[number]; + if (maximum < numbers[number]) + maximum = numbers[number]; + if (numbers[number] == 0) + break; + } + + for (int number = 0; number < 20; ++number) { + if (numbers[number] == 0) + break; + int spaces = (maximum - numbers[number]) / 2; + for (int space = 0; space < spaces; ++space) + cout << " "; + for (int asterisk = 0; asterisk < numbers[number]; ++asterisk) + cout << "*"; + cout << endl; + } + return 0; +} diff --git a/Lesson_2/Task_3/.gitignore b/Lesson_2/Task_3/.gitignore new file mode 100644 index 0000000..4a0b530 --- /dev/null +++ b/Lesson_2/Task_3/.gitignore @@ -0,0 +1,74 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* +CMakeLists.txt.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/Lesson_2/Task_3/main.cpp b/Lesson_2/Task_3/main.cpp new file mode 100644 index 0000000..4f83114 --- /dev/null +++ b/Lesson_2/Task_3/main.cpp @@ -0,0 +1,27 @@ +#include + +using namespace std; + +int main() +{ + int numbers[5]; + int max = 0; + for (int number = 0; number < 5; ++number) { + cout << "Enter amount in " << number + 1 << " row: "; + cin >> numbers[number]; + if (numbers[number] > max) + max = numbers[number]; + } + + for (int iteration = 0; iteration < max; ++iteration) { + for (int number = 0; number < 5; ++number) { + if (iteration < numbers[number]) + cout << "*"; + else + cout << " "; + } + cout << endl; + } + + return 0; +} diff --git a/Lesson_2/Task_4/.gitignore b/Lesson_2/Task_4/.gitignore new file mode 100644 index 0000000..4a0b530 --- /dev/null +++ b/Lesson_2/Task_4/.gitignore @@ -0,0 +1,74 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* +CMakeLists.txt.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/Lesson_2/Task_4/main.cpp b/Lesson_2/Task_4/main.cpp new file mode 100644 index 0000000..a81d275 --- /dev/null +++ b/Lesson_2/Task_4/main.cpp @@ -0,0 +1,22 @@ +#include + +using namespace std; + +int main() +{ + char str[256]; + cout << "Enter some string: "; + cin.getline(str, 256); + int words = 1; + + for (int character = 0; character < 256; ++character) { + if (str[character] == ' ') + ++words; + else if (str[character] == 0) + break; + } + + cout << "Number of words: " << words << endl; + + return 0; +} diff --git a/README.md b/README.md index 10ee443..e9ec294 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,10 @@ Checked means the task is Done. - [x] Task 5 - [x] Task 6 - [x] Task 7 + +### Lesson 2 + +- [ ] Task 1 +- [ ] Task 2 +- [ ] Task 3 +- [ ] Task 4