├── .gitignore ├── Exercises1 ├── CMakeLists.txt └── main.cpp ├── Exercises10 ├── CMakeLists.txt └── main.cpp ├── Exercises11 ├── .idea │ ├── Exercises11.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises12 ├── .gitignore ├── CMakeLists.txt └── main.cpp ├── Exercises13 ├── .idea │ ├── Exercises13.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises14 ├── .idea │ ├── Exercises14.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises15 ├── .idea │ ├── misc.xml │ ├── modules.xml │ ├── untitled.iml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises16 ├── .idea │ ├── Exercises16.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises17 ├── .idea │ ├── Exercises 17.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises18 ├── .idea │ ├── Exercises18.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises19 ├── .idea │ ├── Exercises19.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises2 ├── CMakeLists.txt └── main.cpp ├── Exercises20 ├── .idea │ ├── Exercises20.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises21 ├── .idea │ ├── Exercises21.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises22 ├── .idea │ ├── Exercises22.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises23 ├── .idea │ ├── Exercises23.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises24 ├── .idea │ ├── Exercises24.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises25 ├── .idea │ ├── Exercises25.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises26 ├── .idea │ ├── Exercises26.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises27 ├── .idea │ ├── Exercises27.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises28 ├── .idea │ ├── Exercises28.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises29 ├── .idea │ ├── Exercises29.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises3 ├── CMakeLists.txt └── main.cpp ├── Exercises30 ├── .idea │ ├── Exercises30.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises31 ├── .idea │ ├── Exercise31.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt └── main.cpp ├── Exercises4 ├── CMakeLists.txt └── main.cpp ├── Exercises5 ├── CMakeLists.txt └── main.cpp ├── Exercises6 ├── CMakeLists.txt └── main.cpp ├── Exercises7 ├── CMakeLists.txt └── main.cpp ├── Exercises8 ├── CMakeLists.txt └── main.cpp ├── Exercises9 ├── CMakeLists.txt └── main.cpp ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | -------------------------------------------------------------------------------- /Exercises1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercise1) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercise1 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises1/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | // EXERCISE 1 3 | // Write a program that asks the user to type an integer and writes "YOU WIN" if the value is between 56 and 78 (both included). In the other case it writes "YOU LOSE". 4 | 5 | #include 6 | using namespace std; 7 | 8 | int main() { 9 | 10 | int i; 11 | cout << "Type an integer" << endl; 12 | cin >> i; 13 | 14 | if (i >= 56 && i <= 78 ){ 15 | cout << " YOU WIN " << endl; 16 | }else{ 17 | cout << " YOU LOSE " << endl; 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /Exercises10/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises10) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises10 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises10/main.cpp: -------------------------------------------------------------------------------- 1 | // Exercises 10 2 | 3 | /* 4 | Write a program that is able to compute some operations on an integer. The program writes the value of the integer and writes the following menu : 5 | 6 | 1. Add 1 7 | 2. Multiply by 2 8 | 3. Subtract 4 9 | 4. Quit 10 | 11 | The programs ask the user to type a value between 1 and 4. If the user types a value from 1 to 3 the operation is computed, the integer is written and the menu is displayed again. If the user types 4, the program quits. 12 | 13 | */ 14 | 15 | #include 16 | 17 | using namespace std; 18 | 19 | int main() { 20 | 21 | int input; 22 | int process; 23 | cout << "Type an integer for calculation" << endl; 24 | cin >>input; 25 | while(true){ 26 | cout << "Choose one of the following operations for your integer:\n" 27 | << "1. Add 1\n" 28 | << "2. Multiply by 2\n" 29 | << "3. Subtract 4\n" 30 | << "4. Quit\n" 31 | << "Your choice: "; 32 | cin >> process; 33 | switch (process){ 34 | case 1: {input++; break;} 35 | case 2: {input *=2; break;} 36 | case 3: {input-=4; break;} 37 | case 4: {cout << "Bye bye..."; return 0;} 38 | default: {break;} 39 | } 40 | cout << endl << "Answer : " << input << endl; 41 | } 42 | 43 | 44 | } -------------------------------------------------------------------------------- /Exercises11/.idea/Exercises11.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises11/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises11/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises11/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises11) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises11 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises11/main.cpp: -------------------------------------------------------------------------------- 1 | // Exercises 11 2 | /* 3 | * Write a program that asks the user to type a positive integer. When the user types a negative value the program writes ERROR and asks for another value. 4 | * When the user types 0, that means that the last value has been typed and the program must write the average of the positive integers. 5 | * If the number of typed values is zero the program writes 'NO AVERAGE'. 6 | */ 7 | 8 | #include 9 | 10 | using namespace std; 11 | 12 | int main() { 13 | 14 | int input; 15 | int sum=0; 16 | int count=0; 17 | do { 18 | cout << "Please type a positive integer value. (Type '0' when you want to calculate an average)" << endl; 19 | cin>>input; 20 | if (input < 0){ 21 | cout << "ERROR, please type positive integer value "<< endl; 22 | continue; 23 | }else if(input > 0){ 24 | sum += input; 25 | count++; 26 | }else if(input==0){ 27 | if (count == 0){ 28 | cout << "NO AVERAGE" << endl; 29 | }else{ 30 | cout << "AVERAGE IS " << sum/count << endl; 31 | } 32 | } 33 | } while (input!=0); 34 | } -------------------------------------------------------------------------------- /Exercises12/.gitignore: -------------------------------------------------------------------------------- 1 | ### C++ template 2 | # Compiled Object files 3 | *.slo 4 | *.lo 5 | *.o 6 | *.obj 7 | 8 | # Precompiled Headers 9 | *.gch 10 | *.pch 11 | 12 | # Compiled Dynamic libraries 13 | *.so 14 | *.dylib 15 | *.dll 16 | 17 | # Fortran module files 18 | *.mod 19 | 20 | # Compiled Static libraries 21 | *.lai 22 | *.la 23 | *.a 24 | *.lib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | 31 | # Created by .ignore support plugin (hsz.mobi) 32 | -------------------------------------------------------------------------------- /Exercises12/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises12) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises12 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises12/main.cpp: -------------------------------------------------------------------------------- 1 | // Exercises 12 2 | /* 3 | Write a program that asks the user to type an integer N and compute u(N) defined with : 4 | u(0)=3 5 | u(1)=2 6 | u(n)=n*u(n-1)+(n+1)*u(n-2)+n 7 | */ 8 | 9 | #include 10 | 11 | using namespace std; 12 | 13 | 14 | int u(int n){ 15 | 16 | if (n==0) 17 | return 3; 18 | if(n==1) 19 | return 2; 20 | else 21 | return n*u(n-1)+(n+1)*u(n-2)+n; 22 | 23 | } 24 | 25 | int main() { 26 | 27 | int input; 28 | 29 | cout << "Please type an integer value: " << endl; 30 | cin >> input; 31 | 32 | cout << "Your value is " << u(input); 33 | 34 | 35 | 36 | 37 | 38 | } -------------------------------------------------------------------------------- /Exercises13/.idea/Exercises13.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises13/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises13/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises13/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 64 | 65 | 66 | 67 | 68 | true 69 | 70 | 71 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 139 | 140 | 141 | 142 | 1461744390780 143 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | -------------------------------------------------------------------------------- /Exercises13/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises13) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises13 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises13/main.cpp: -------------------------------------------------------------------------------- 1 | // Exercises 13 2 | // Write a program that asks the user to type 10 integers and write the number of occurrence of the biggest value. 3 | 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | int main() { 10 | 11 | 12 | int input; 13 | int big = 0; 14 | vector arr; 15 | 16 | cout << "Please type 10 integers and machine will find biggest value"<< endl; 17 | 18 | for (int i = 0; i < 9; i++) { 19 | cin >> input; 20 | arr.push_back(input); 21 | } 22 | 23 | for (int j = 0; j < 9; j++) { 24 | if (arr[j] > big) { 25 | big = arr[j]; 26 | } 27 | } 28 | 29 | cout << "Biggest value is: " << big << endl; 30 | 31 | } -------------------------------------------------------------------------------- /Exercises14/.idea/Exercises14.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises14/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises14/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises14/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 62 | 63 | 64 | 65 | 66 | true 67 | 68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 137 | 138 | 139 | 140 | 1461745326768 141 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | -------------------------------------------------------------------------------- /Exercises14/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises14) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises14 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises14/main.cpp: -------------------------------------------------------------------------------- 1 | // Exercises 14 2 | // Write a program that asks the user to type the value of N and computes N! . 3 | 4 | 5 | 6 | #include 7 | 8 | using namespace std; 9 | 10 | int f(int n) { 11 | return (n == 1 ? n : n * f(n - 1)); 12 | } 13 | 14 | 15 | int main() { 16 | 17 | cout << "Please type an integer for computes N!" << endl; 18 | 19 | int input; 20 | 21 | cin >> input; 22 | 23 | 24 | cout << input << "! = " << f(input) << endl; 25 | } -------------------------------------------------------------------------------- /Exercises15/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | CSS 17 | 18 | 19 | Probable bugsCSS 20 | 21 | 22 | RELAX NG 23 | 24 | 25 | XPath 26 | 27 | 28 | XSLT 29 | 30 | 31 | 32 | 33 | BashSupport 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Exercises15/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises15/.idea/untitled.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises15/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(untitled) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(untitled ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises15/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Exercises 15 3 | * Write a program that asks the user to type an integer N and that indicates if N is a prime number or not. 4 | */ 5 | 6 | 7 | #include 8 | 9 | using namespace std; 10 | 11 | int main() { 12 | 13 | int input; 14 | cout << "Please enter an integer. Machine will tell the number, prime number or not" << endl; 15 | 16 | cin >> input; 17 | 18 | 19 | for (int i = 2; i < input; i++) { 20 | if(input % i == 0){ 21 | cout << input << " <- Not prime number" << endl; 22 | break; 23 | }else{ 24 | cout << input << " <- Prime number " < 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises16/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises16/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises16/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises16) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises16 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises16/main.cpp: -------------------------------------------------------------------------------- 1 | /* Exercises 16 2 | * Write a program that asks the user to type an integer N and that writes the number of prime numbers lesser or equal to N. 3 | */ 4 | 5 | 6 | #include 7 | 8 | 9 | using namespace std; 10 | 11 | bool is_prime(int n){ 12 | for (int i = 2; i < n ; i++) { 13 | if ((n%i) ==0){ 14 | return false; 15 | } 16 | } 17 | return true; 18 | } 19 | 20 | 21 | 22 | int main(){ 23 | int input = 0; 24 | 25 | cout << "Please type an integer value : "; 26 | cin >> input; 27 | 28 | for (int i = 2; i <= input ; i++) { 29 | if (is_prime(i)){ 30 | cout << i << endl; 31 | } 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Exercises17/.idea/Exercises 17.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises17/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises17/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises17/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises_17) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises_17 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises17/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Exercises 17 3 | * Write a program that asks the user to type the value of an integer N and compute the N-st prime number. 4 | */ 5 | 6 | #include 7 | 8 | 9 | using namespace std; 10 | 11 | bool is_prime(int n){ 12 | for (int i = 2; i < n ; i++) { 13 | if ((n%i) ==0){ 14 | return false; 15 | } 16 | } 17 | return true; 18 | } 19 | 20 | 21 | int main(){ 22 | int input = 0; 23 | int count = 0; 24 | cout << "Please type an integer value : "; 25 | cin >> input; 26 | 27 | for (int i = 2; i <= input ; i++) { 28 | if (is_prime(i)){ 29 | count++; 30 | cout << count << ". prime number - >" << i << endl; 31 | } 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /Exercises18/.idea/Exercises18.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises18/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises18/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises18/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises18) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises18 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises18/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Exercises 18 3 | * Write a program that asks the user to type the value of N and writes this picture: 4 | N=1 5 | * 6 | N=2 7 | ** 8 | * 9 | N=3 10 | *** 11 | ** 12 | * 13 | and so on... 14 | */ 15 | 16 | #include 17 | 18 | using namespace std; 19 | 20 | int main() { 21 | 22 | 23 | int input; 24 | bool condition = true; 25 | cout << "Please type an integer value" << endl; 26 | cin >> input; 27 | 28 | 29 | while (condition) { 30 | for (int i = 0; i 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises19/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises19/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises19/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 62 | 63 | 64 | 65 | 66 | true 67 | 68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 137 | 138 | 139 | 140 | 1462030834703 141 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /Exercises19/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises19) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises19 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises19/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Write a program that asks the user to type the value of N and display an output like the following: 3 | 4 | N=1 5 | * 6 | N=2 7 | ** 8 | * 9 | N=3 10 | *** 11 | ** 12 | * 13 | */ 14 | 15 | 16 | #include 17 | 18 | using namespace std; 19 | 20 | 21 | int main() { 22 | 23 | int input; 24 | int space = 0; 25 | bool condition = true; 26 | cout << "Please type an integer value" << endl; 27 | cin >> input; 28 | 29 | 30 | while (condition) { 31 | 32 | 33 | for (int j = 0; j < space; j++) { 34 | cout << " "; 35 | } 36 | space++; 37 | 38 | for (int i = 0; i < input; i++) { 39 | cout << "*"; 40 | } 41 | input--; 42 | cout << endl; 43 | 44 | 45 | if (input == 0) { 46 | condition = false; 47 | } 48 | } 49 | 50 | 51 | } -------------------------------------------------------------------------------- /Exercises2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises2) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises2 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises2/main.cpp: -------------------------------------------------------------------------------- 1 | //Exercise 2 2 | //Write a program that asks the user to type all the integers between 8 and 23 (both included) using a for loop. 3 | 4 | #include 5 | using namespace std; 6 | 7 | int main() { 8 | 9 | int currentNumber = 8; 10 | int inputNumber; 11 | 12 | for (int i = 8; i < 24; i++) { 13 | cout << "Type " << i; 14 | cin >> inputNumber; 15 | 16 | if (inputNumber != currentNumber) { 17 | i -= 1; 18 | } else { 19 | currentNumber += 1; 20 | } 21 | } 22 | 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Exercises20/.idea/Exercises20.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises20/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises20/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises20/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises20) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises20 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises20/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Exercises 20 3 | * 4 | * u(n) defined with 5 | * u(0) =a (a is an integer) 6 | * if u(n) is even then 7 | * u(n+1) = u(n)/2, else 8 | * u(n+1) = 3*u(n)+1 9 | * 10 | * Conjecture : For all value of a, there exist a value N such that u(N) = 1 11 | * 12 | * 13 | * a) Write program that asks the user to type the value of an integer a and writes all the values of u(n) from n=1 to n=N 14 | */ 15 | 16 | #include 17 | 18 | using namespace std; 19 | 20 | 21 | 22 | 23 | int main() { 24 | int a,n,u; 25 | cout<<"Type the value of a : ";cin>>a; 26 | n=0; 27 | u=a; 28 | 29 | while(u!=1) 30 | { 31 | if(u%2==0)u=u/2; else u=3*u+1; 32 | n++; 33 | cout<<"u("< 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises21/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises21/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises21/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises21) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises21 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises21/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* Exercises 21 3 | * 4 | * Request the user to type numbers, each time printing its triple, until the user enter -999 5 | * 6 | */ 7 | 8 | 9 | 10 | #include 11 | 12 | using namespace std; 13 | 14 | int main() { 15 | 16 | int input ; 17 | bool condition = true; 18 | 19 | cout << "Please type a number. If want to quit type '-999'" << endl; 20 | 21 | while(condition){ 22 | cin>>input; 23 | if (input==-999){ 24 | condition=false; 25 | exit(0); 26 | }else{ 27 | input*=3; 28 | cout << input << endl; 29 | 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Exercises22/.idea/Exercises22.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises22/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises22/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises22/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 62 | 63 | 64 | 65 | 66 | true 67 | 68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 137 | 138 | 139 | 140 | 1462047699673 141 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 174 | 175 | 176 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | -------------------------------------------------------------------------------- /Exercises22/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises22) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises22 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises22/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Exercises 22 3 | * 4 | * Request the user type positive numbers until either a zero or negative is typed, and then show the user how many positives were typed in. 5 | */ 6 | 7 | 8 | 9 | #include 10 | 11 | using namespace std; 12 | 13 | int main() { 14 | int input; 15 | int count = 0; 16 | bool condition = true; 17 | 18 | cout << "Please type positive numbers. " << endl; 19 | 20 | while(condition){ 21 | cin >> input; 22 | if (input >0){ 23 | count++; 24 | }else{ 25 | cout << "You typed " << count << " positive numbers" << endl; 26 | condition = false; 27 | } 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /Exercises23/.idea/Exercises23.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises23/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises23/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises23/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 62 | 63 | 64 | 65 | 66 | true 67 | 68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 137 | 138 | 139 | 140 | 1462048172589 141 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | -------------------------------------------------------------------------------- /Exercises23/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises23) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises23 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises23/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Exercises 23 3 | * 4 | * Request the user to type positive numbers, or to stop by typing a number smaller than 1. Print the average. 5 | * 6 | */ 7 | 8 | 9 | #include 10 | 11 | using namespace std; 12 | 13 | int main() { 14 | 15 | int input; 16 | int result = 0; 17 | int count = 0; 18 | bool condition = true; 19 | int sum = 0; 20 | 21 | 22 | 23 | while (condition) { 24 | cin >> input; 25 | if (input > 1) { 26 | sum += input; 27 | count++; 28 | } else { 29 | result = sum / count; 30 | cout << "You typed " << count << " positive numbers and average is " << result << endl; 31 | condition = false; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Exercises24/.idea/Exercises24.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises24/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises24/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises24/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 62 | 63 | 64 | 65 | 66 | true 67 | 68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 138 | 139 | 140 | 141 | 1462049046005 142 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | -------------------------------------------------------------------------------- /Exercises24/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises24) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises24 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises24/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Exercise 24 3 | * 4 | * Request the user to type numbers, or type 0 to stop. 5 | * Show how many numbers were between 100 and 200 (both included) 6 | * 7 | */ 8 | 9 | 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | int main() { 16 | 17 | int input; 18 | int count = 0; 19 | bool condition = true; 20 | 21 | cout << "Please typed numbers. Type 0 for exit" << endl; 22 | 23 | while (condition) { 24 | cin >> input; 25 | if (input > 99 && input < 201) { 26 | count++; 27 | } else if (input == 0) { 28 | cout << "You typed " << count << " numbers between 100 and 200" << endl; 29 | condition = false; 30 | exit(0); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Exercises25/.idea/Exercises25.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises25/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises25/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises25/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 62 | 63 | 64 | 65 | 66 | true 67 | 68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 138 | 139 | 140 | 141 | 1462049539953 142 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | -------------------------------------------------------------------------------- /Exercises25/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises25) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises25 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises25/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Exercise 25 3 | * 4 | * The country A has 50M inhabitants, and its population grows 3% per year. The country B, 70M and grows 2% per year. 5 | * Tell in how many years A will surpass B. 6 | */ 7 | 8 | 9 | 10 | #include 11 | 12 | using namespace std; 13 | 14 | int main() { 15 | 16 | double countryA = 50; 17 | double countryB = 70; 18 | int count = 0; 19 | 20 | 21 | while (countryB>countryA) { 22 | countryA = countryA + (countryA/100)*3; 23 | countryB = countryB +(countryB/100)*2; 24 | count++; 25 | } 26 | 27 | cout << "in " << count << " years countryA will have a greater population than countryB" << endl; 28 | 29 | 30 | 31 | 32 | } -------------------------------------------------------------------------------- /Exercises26/.idea/Exercises26.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises26/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises26/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises26/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises26) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises26 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises26/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Exercise 26 3 | * 4 | * Write a program that asks the user to input 5 sequences of characters. Then it will ask the user for a character to search for and will output the maximum number of times that it occurred between 5 | * the 5 sequences. 6 | * Example: 7 | * Sequence 1: aabc 8 | * Sequence 2: aaaa 9 | * If the user chooses to search for character 'a', the program will output "Character a occurred a maximum of 4 times" because it occurred 4 times in the second sequence, and only twice in the first sequence. 10 | * 11 | */ 12 | 13 | 14 | #include 15 | 16 | using namespace std; 17 | int look_for_char(const string &s, char ch) 18 | { 19 | int cnt = 0; 20 | for (int i = 0; i < s.size(); i++) 21 | { 22 | if (ch == s[i]) 23 | cnt++; 24 | } 25 | return cnt; 26 | } 27 | 28 | int main() 29 | { 30 | string a, b, c, d, e; 31 | char ch; 32 | int ia, ib, ic, id, ie, iMax = 0; 33 | cout << "Please enter 5 sequences of characters:" << endl; 34 | cin >> a >> b >> c >> d >> e; 35 | cout << "Enter character that you are looking for: "; 36 | cin >> ch; 37 | ia = look_for_char(a, ch); 38 | if (iMax < ia) 39 | iMax = ia; 40 | ib = look_for_char(b, ch); 41 | if (iMax < ib) 42 | iMax = ib; 43 | ic = look_for_char(c, ch); 44 | if (iMax < ic) 45 | iMax = ic; 46 | id = look_for_char(d, ch); 47 | if (iMax < id) 48 | iMax = id; 49 | ie = look_for_char(e, ch); 50 | if (iMax < ie) 51 | iMax = ie; 52 | 53 | cout << "Character " << ch << " has been typed - " << iMax << " times.\n"; 54 | return 0; 55 | } -------------------------------------------------------------------------------- /Exercises27/.idea/Exercises27.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises27/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises27/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises27/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises27) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises27 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises27/main.cpp: -------------------------------------------------------------------------------- 1 | /* Exercise 27 2 | * 3 | * Write a program that asks the user to type a random number. Write in output if this numbers is a prime number or not. Write, by which numbers can your number be divided. 4 | * 5 | * 6 | */ 7 | 8 | 9 | #include 10 | #include 11 | 12 | 13 | using namespace std; 14 | 15 | int main() { 16 | 17 | int input; 18 | vector arr; 19 | cin >> input; 20 | cout << "Please type an integer. "<< endl; 21 | 22 | for (int i = 2; i <= input / 2 ; i++) { 23 | if (input % i == 0){ 24 | arr.push_back(i); 25 | } 26 | } 27 | 28 | if (arr.empty()){ 29 | cout << "Prime number" << endl; 30 | } 31 | 32 | for(int arrs: arr){ 33 | cout << "This number can divide your random number -> "<< arrs << endl; 34 | } 35 | } -------------------------------------------------------------------------------- /Exercises28/.idea/Exercises28.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises28/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises28/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises28/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises28) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises28 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises28/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Exercise 28 4 | * 5 | * Write a program for finding the amount of a specific character inside a string 6 | * 7 | */ 8 | 9 | 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | 16 | int main() { 17 | 18 | string input, character; 19 | vector arr; 20 | 21 | cout <<"Type a string: " << endl; 22 | cin >> input; 23 | 24 | cout << "What is that one character are you looking for? "<< endl; 25 | cin >> character; 26 | 27 | for (int i = 0; i <= arr.size(); i++) { 28 | 29 | } 30 | 31 | 32 | 33 | } -------------------------------------------------------------------------------- /Exercises29/.idea/Exercises29.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises29/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises29/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises29/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises29) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises29 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises29/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Exercises 29 3 | * 4 | * Write a program to find out no. of Even & Odd no. in a given Data Series. 5 | * 6 | */ 7 | 8 | #include 9 | 10 | using namespace std; 11 | 12 | int main() { 13 | unsigned data[]{0,1,2,3,4,5,6,7,8,9}, even_n{0}, odd_n{0}; 14 | cout <<"given nubmers " ; 15 | for (auto &tmp: data){ 16 | cout << tmp << " "; 17 | if (tmp%2==0) { 18 | even_n++; 19 | }else{ 20 | odd_n++; 21 | } 22 | 23 | cout << "\nEven no. " << even_n << endl; 24 | cout << "Oddn no " << odd_n << endl; 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /Exercises3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises3) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises3 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises3/main.cpp: -------------------------------------------------------------------------------- 1 | //Exercises 3 2 | //Write a program that asks the user to type all the integers between 8 and 23 (both included) using a while. 3 | 4 | #include 5 | using namespace std; 6 | 7 | 8 | int main() { 9 | 10 | int currentNumber = 8; 11 | int inputNumber; 12 | 13 | bool condition = true; 14 | 15 | while(condition){ 16 | cout << "Type "<< currentNumber<< endl; 17 | cin >> inputNumber; 18 | if(currentNumber!=inputNumber){ 19 | cout << "Please follow the instructors" << endl; 20 | }else{ 21 | currentNumber+=1; 22 | } 23 | 24 | if (currentNumber == 24){ 25 | condition= false; 26 | cout << "End of the While loop"; 27 | } 28 | 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /Exercises30/.idea/Exercises30.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises30/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises30/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises30/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 62 | 63 | 64 | 65 | 66 | true 67 | 68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 137 | 138 | 139 | 140 | 1462112188875 141 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /Exercises30/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises30) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises30 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises30/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Exercise 30 4 | * 5 | * Write a program to count Zero, Positive, Negative no. in a given Data Series 6 | * 7 | */ 8 | 9 | 10 | #include 11 | 12 | using namespace std; 13 | 14 | int main() { 15 | cout << "Hello, World!" << endl; 16 | return 0; 17 | } -------------------------------------------------------------------------------- /Exercises31/.idea/Exercise31.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Exercises31/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | CSS 18 | 19 | 20 | Probable bugsCSS 21 | 22 | 23 | RELAX NG 24 | 25 | 26 | XPath 27 | 28 | 29 | XSLT 30 | 31 | 32 | 33 | 34 | BashSupport 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Exercises31/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Exercises31/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercise31) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercise31 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises31/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Exercise 31 3 | * 4 | * Write a program to count the numbers which are divisible by 3 in a given Data Series 5 | * 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | using namespace std; 12 | 13 | int main() { 14 | 15 | int howManyNumbers; 16 | int input; 17 | vector dataSeries; 18 | 19 | cout << "How many numbers do you want to add to Data Series" << endl; 20 | cin >> howManyNumbers; 21 | cout << "Please add " << howManyNumbers << " numbers " << endl; 22 | 23 | for (int i = 0; i < howManyNumbers; i++) { 24 | cout << "Please type " << i + 1 << "th number : "; 25 | cin >> input; 26 | dataSeries.push_back(input); 27 | } 28 | 29 | cout << "These numbers can divisible by 3" << endl; 30 | 31 | for (int divisible: dataSeries) { 32 | if (divisible % 3 == 0) { 33 | cout << divisible << endl; 34 | } 35 | 36 | } 37 | 38 | 39 | } -------------------------------------------------------------------------------- /Exercises4/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises4) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises4 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises4/main.cpp: -------------------------------------------------------------------------------- 1 | // Exercises 4 2 | // Write a program that asks the user to type 10 integers and writes the sum of these integers. 3 | 4 | #include 5 | using namespace std; 6 | 7 | int main() { 8 | 9 | int input; 10 | int sum = 0; 11 | for (int i = 1; i <= 10; i++) { 12 | cout << "Enter the " << i << "th number" <> input; 14 | sum +=input; 15 | } 16 | 17 | cout<< "Sum: " << sum << endl;1 18 | 19 | } -------------------------------------------------------------------------------- /Exercises5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises5) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises5 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises5/main.cpp: -------------------------------------------------------------------------------- 1 | // Exercises 5 2 | // Write a program that asks the user to type 10 integers and writes the smallest value. 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | int main() { 11 | 12 | int input; 13 | vector vec; 14 | cout << "Type 10 integers" << endl; 15 | 16 | for (int i = 0; i < 10; i++) { 17 | 18 | cin >> input; 19 | vec.push_back(input); 20 | } 21 | 22 | sort(vec.begin(), vec.end()); 23 | 24 | cout << "Smallest value is " << vec[0]; 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /Exercises6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises6) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises6 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises6/main.cpp: -------------------------------------------------------------------------------- 1 | // Exercises 6 2 | // Write a program that asks the user to type an integer N and computes the sum of the cubes from 5^3 to N^3. 3 | 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | int main() { 10 | 11 | double input; 12 | double pwr = 5; 13 | double sum = 0; 14 | 15 | cout << "Please type an integer " << endl; 16 | cin >> input; 17 | 18 | double count = input - pwr; 19 | 20 | if (count < 0) { 21 | count = count * -1; 22 | for (int i = 0; i <= count; ++i) { 23 | sum += pow(pwr, 3); 24 | pwr--; 25 | } 26 | } 27 | 28 | if (count > 0) { 29 | for (int i = 0; i <= count; i++) { 30 | sum += pow(pwr, 3); 31 | pwr++; 32 | } 33 | } 34 | 35 | cout << sum << endl; 36 | 37 | } -------------------------------------------------------------------------------- /Exercises7/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises7) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises7 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises7/main.cpp: -------------------------------------------------------------------------------- 1 | // Exercises 7 2 | // Write a program that asks the user to type an integer N and compute u(N) defined with : 3 | // u(0)=3 4 | // u(n+1)=3*u(n)+4 5 | 6 | #include 7 | 8 | using namespace std; 9 | 10 | int main() { 11 | 12 | int input; 13 | int result; 14 | int u = 3; 15 | 16 | 17 | cout << "Please type an integer for calculation" << endl; 18 | cin >> input; 19 | 20 | if (input == 0) { 21 | cout << "u(0) -> " << u << endl; 22 | } else { 23 | for (int i = 1; i <= input; i++) { 24 | result = 3 * u + 4; 25 | u = result; 26 | } 27 | 28 | cout << "u(" << input << ") -> " << result << endl; 29 | 30 | } 31 | 32 | 33 | } -------------------------------------------------------------------------------- /Exercises8/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercises8) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercises8 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises8/main.cpp: -------------------------------------------------------------------------------- 1 | // Exercises 8 2 | // Write a program that asks the user to type an integer N and compute u(N) defined with : 3 | // u(0)=1 4 | // u(1)=1 5 | // u(n+1)=u(n)+u(n-1) 6 | 7 | #include 8 | 9 | using namespace std; 10 | 11 | int main() { 12 | 13 | int input; 14 | int u = 1; 15 | int result; 16 | 17 | cout << "Please type an integer value " << endl; 18 | cin>>input; 19 | 20 | for (int i = 0; i < input; ++i) { 21 | result = u + u - 1; 22 | u = result; 23 | } 24 | 25 | cout << "u(" << input << ") -> " << u << endl; 26 | 27 | 28 | } -------------------------------------------------------------------------------- /Exercises9/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(Exercise9) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(Exercise9 ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Exercises9/main.cpp: -------------------------------------------------------------------------------- 1 | // Exercises9 2 | // Write a program that asks the user to type an integer between 0 and 20 (both included) and writes N+17. If someone types a wrong value, the program writes ERROR and he must type another value. 3 | 4 | 5 | #include 6 | 7 | using namespace std; 8 | 9 | int main() { 10 | 11 | int input; 12 | bool condition = true; 13 | string desc = "Please type an integer between 0 and 20 (both included)"; 14 | 15 | cout << desc << endl; 16 | 17 | 18 | while (condition) { 19 | cin >> input; 20 | if (!(input >= 0 && input <= 20)) { 21 | cout << desc << endl; 22 | } else { 23 | cout << "Sum of the " << input << " + 17 -> " << input+17 << endl; 24 | condition = false; 25 | } 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CPP-Programming-Exercises 2 | C++ Programming Exercises 3 | --------------------------------------------------------------------------------