|
| 1 | +#include <iostream> |
| 2 | + using namespace std; |
| 3 | + |
| 4 | + |
| 5 | + int main(){ |
| 6 | + |
| 7 | + |
| 8 | +int runner =0; |
| 9 | +int pick; |
| 10 | + while(runner==0){ |
| 11 | + |
| 12 | + cout << "\n"; |
| 13 | +cout << "----------------------------------" << "\n"; |
| 14 | +cout << "+___________MAIN MENU____________+" << "\n"; |
| 15 | +cout << "----------------------------------" << "\n"; |
| 16 | +cout << "+ [1.] One-Dimentional Array +" << "\n"; |
| 17 | +cout << "+ [2.] Multi-Dimentional Array +" << "\n"; |
| 18 | +cout << "+ [3.] E X I T +" << "\n"; |
| 19 | +cout << "==================================" << "\n"; |
| 20 | +cout << " Please select an Operation [1-3]" << "\n"; |
| 21 | + cin >> pick; |
| 22 | +switch(pick){ |
| 23 | + |
| 24 | + case 1: { |
| 25 | + cout << "\n"; |
| 26 | +cout << "= = = One-Dimentional Array = = =" << "\n"; |
| 27 | + |
| 28 | + int put1; |
| 29 | + int ray[5]; |
| 30 | + int put; |
| 31 | + cout << " Enter # of Elements: "; |
| 32 | + cin >> put; |
| 33 | + |
| 34 | + |
| 35 | + for(int exodia=0; exodia<put; exodia++){ |
| 36 | + cout << " " << "[ " << " " << exodia << " " << " ]"; |
| 37 | + cin >> ray[exodia]; |
| 38 | + } |
| 39 | + cout << "\n"; |
| 40 | + cout << "===================================" << "\n"; |
| 41 | + cout << "= [ 1 ] D E L E T E =" << "\n"; |
| 42 | + cout << "= [ 2 ] S E A R C H =" << "\n"; |
| 43 | + cout << "= [ 3 ] U P D A T E =" << "\n"; |
| 44 | + cout << "===================================" << "\n"; |
| 45 | + cout << "Enter an Operation [1-3]: "; |
| 46 | + |
| 47 | + |
| 48 | + cin >> put1; |
| 49 | + |
| 50 | + switch(put1){ |
| 51 | + |
| 52 | + case 1:{ |
| 53 | +char pili1; |
| 54 | + |
| 55 | + |
| 56 | + cout << " Enter Index Pos. to Delete: "; |
| 57 | + int erad; |
| 58 | + cin >> erad; |
| 59 | + int rase=erad; |
| 60 | + while(rase < put){ |
| 61 | + ray[rase-1]=ray[rase]; |
| 62 | + rase=rase+1; |
| 63 | + } |
| 64 | + put=put-1; |
| 65 | + for(int eyodia=0; eyodia<put; eyodia++){ |
| 66 | + cout << " " << ray[eyodia] << " "; |
| 67 | + cout << " "; |
| 68 | + |
| 69 | + |
| 70 | + } |
| 71 | + cout << "\n"; |
| 72 | + cout << "\n"; |
| 73 | + |
| 74 | + break; |
| 75 | + |
| 76 | + |
| 77 | + } |
| 78 | + |
| 79 | + case 2:{ |
| 80 | + int ser; |
| 81 | + cout << " Enter # to Search in the Elements: "; |
| 82 | + int find; |
| 83 | + cin >> find; |
| 84 | + ser=0; |
| 85 | + while(ser < put ){ |
| 86 | + if(ray[ser]==find){ |
| 87 | + break; |
| 88 | + } |
| 89 | + ser=ser+1; |
| 90 | + } |
| 91 | + cout << " The Position of " << find << " is " << ser << " \n "; |
| 92 | + cout << " \n "; |
| 93 | + break; |
| 94 | + } |
| 95 | + case 3:{ |
| 96 | + int upd; |
| 97 | + cout << "Enter # Position to Update: "; |
| 98 | + cin >> upd; |
| 99 | + cout << "Enter #: "; |
| 100 | + int updnum; |
| 101 | + cin >> updnum; |
| 102 | + ray[upd-1]=updnum; |
| 103 | + for(int ewodia=0; ewodia<put; ewodia++){ |
| 104 | + cout << ray[ewodia] << " "; |
| 105 | + |
| 106 | + } |
| 107 | + |
| 108 | + } |
| 109 | +} |
| 110 | + break; |
| 111 | +} |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + case 2: { |
| 118 | + int put2; |
| 119 | + int ray[2][3]; |
| 120 | + int hori,verti; |
| 121 | + cout << "\n"; |
| 122 | + cout << "* * * Multi-Dimentional Array * * *" << "\n"; |
| 123 | + |
| 124 | + cout<< "Enter # of Row: "; |
| 125 | + cin >> hori; |
| 126 | + cout << "Enter # of Column: "; |
| 127 | + cin >> verti; |
| 128 | + |
| 129 | + for(int exodia=0; exodia<hori; exodia++){ |
| 130 | + for (int eyodia=0; eyodia<verti; eyodia++){ |
| 131 | + |
| 132 | + cout << " [ " << exodia << " ]" << "[ " << eyodia << " ]"; |
| 133 | + cin >> ray[exodia][eyodia]; |
| 134 | + |
| 135 | + } |
| 136 | + } |
| 137 | + cout << "\n"; |
| 138 | + cout << "* * * Multi-Dimentional Array * * *" << "\n"; |
| 139 | + cout << "***********************************" << "\n"; |
| 140 | + cout << "* [ 1 ] S E A R C H *" << "\n"; |
| 141 | + cout << "* [ 2 ] U P D A T E *" << "\n"; |
| 142 | + cout << "***********************************" << "\n"; |
| 143 | + cout << "Enter an Operation [1-2]: "; |
| 144 | + cin >> put2; |
| 145 | + |
| 146 | + switch(put2){ |
| 147 | + case 1:{ |
| 148 | + |
| 149 | + int find; |
| 150 | + cout << " Enter # to Search: "; |
| 151 | + cin >> find; |
| 152 | + |
| 153 | + |
| 154 | + |
| 155 | + for(int exodia=0; exodia<hori; exodia++){ |
| 156 | + for (int eyodia=0; eyodia<verti; eyodia++){ |
| 157 | + if(ray[exodia][eyodia]==find){ |
| 158 | + cout << " The # " << find << " is in the Pos. of: " << exodia << " " << eyodia; |
| 159 | + cout << "\n"; |
| 160 | + } |
| 161 | + } |
| 162 | +} |
| 163 | + break; |
| 164 | + } |
| 165 | + |
| 166 | + |
| 167 | + case 2:{ |
| 168 | + |
| 169 | + int repl, rr, cc; |
| 170 | + cout << " Enter # of Row & Column to Update: " << " \n"; |
| 171 | + cout << " Row: "; |
| 172 | + cin>> rr; |
| 173 | + cout << " Column: "; |
| 174 | + cin>> cc; |
| 175 | + |
| 176 | + cout << "Enter # to Replace: "; |
| 177 | + cin >> repl; |
| 178 | + |
| 179 | + ray[rr][cc]=repl; |
| 180 | + for(int exodia=0; exodia<hori; exodia++){ |
| 181 | + for (int eyodia=0; eyodia<verti; eyodia++){ |
| 182 | + cout << ray[exodia][eyodia] << " "; |
| 183 | + |
| 184 | +} |
| 185 | + |
| 186 | +} |
| 187 | + cout << "\n"; |
| 188 | + break; |
| 189 | + } |
| 190 | + exit(0); |
| 191 | + } |
| 192 | + |
| 193 | + break; |
| 194 | + |
| 195 | + } |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | + default: |
| 204 | + cout << "Error Operation only [1-3]" << " \n "; |
| 205 | + runner = true; |
| 206 | + cout << " \n "; |
| 207 | + } |
| 208 | + cout << "\n"; |
| 209 | +cout << "Back to the Main Menu? Yes[0] || [1]No "; |
| 210 | + cin >> runner; |
| 211 | + |
| 212 | +if(runner==0){ |
| 213 | + system("cls"); |
| 214 | + runner=0; |
| 215 | + |
| 216 | +}else { |
| 217 | + runner=1; |
| 218 | +exit(0); |
| 219 | + |
| 220 | + |
| 221 | +} |
| 222 | +} |
| 223 | + |
| 224 | +return 0; |
| 225 | +} |
0 commit comments