![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Adnan Kičin Armin Kečo
main.cpp@0:f32b917de198, 2014-05-26 (annotated)
- Committer:
- tim008
- Date:
- Mon May 26 15:55:39 2014 +0000
- Revision:
- 0:f32b917de198
Tim008_Grupa3_Kalkulator
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tim008 | 0:f32b917de198 | 1 | #include "mbed.h" |
tim008 | 0:f32b917de198 | 2 | #include "cmath" |
tim008 | 0:f32b917de198 | 3 | #include "string" |
tim008 | 0:f32b917de198 | 4 | |
tim008 | 0:f32b917de198 | 5 | //tastatura |
tim008 | 0:f32b917de198 | 6 | DigitalIn kolone[4]={dp9, dp10, dp11, dp13}; |
tim008 | 0:f32b917de198 | 7 | DigitalOut redovi[4]={dp16, dp15, dp17, dp18}; |
tim008 | 0:f32b917de198 | 8 | // . G F E D C B A |
tim008 | 0:f32b917de198 | 9 | BusOut ekran(dp26,dp27,dp5,dp6,dp28, dp1, dp2, dp4); |
tim008 | 0:f32b917de198 | 10 | // D2 D3 D4 |
tim008 | 0:f32b917de198 | 11 | BusOut cifre(dp23, dp24, dp25); |
tim008 | 0:f32b917de198 | 12 | DigitalOut enable(dp14); |
tim008 | 0:f32b917de198 | 13 | DigitalOut taster1(dp1); // taster jedan |
tim008 | 0:f32b917de198 | 14 | DigitalOut taster2(dp2); // taster dva |
tim008 | 0:f32b917de198 | 15 | // Na 0 se ukljucuju ledice |
tim008 | 0:f32b917de198 | 16 | // 0 1 ... |
tim008 | 0:f32b917de198 | 17 | int brojevi[10]= {0x40, 0xf9, 0x24, 0x30, 0x19, 0x12, 0x02, 0xf8, 0x00, 0x10}; |
tim008 | 0:f32b917de198 | 18 | |
tim008 | 0:f32b917de198 | 19 | char br[] = {'0','0','0'}; |
tim008 | 0:f32b917de198 | 20 | char op=' '; |
tim008 | 0:f32b917de198 | 21 | int memori=0; |
tim008 | 0:f32b917de198 | 22 | |
tim008 | 0:f32b917de198 | 23 | |
tim008 | 0:f32b917de198 | 24 | void taster(){ |
tim008 | 0:f32b917de198 | 25 | int brojac=0; |
tim008 | 0:f32b917de198 | 26 | op = 'X'; |
tim008 | 0:f32b917de198 | 27 | while(brojac<2 || op != 'X'){ |
tim008 | 0:f32b917de198 | 28 | for(int i=0; i<4; i++){ |
tim008 | 0:f32b917de198 | 29 | redovi[i]=1; |
tim008 | 0:f32b917de198 | 30 | if(i==0){ |
tim008 | 0:f32b917de198 | 31 | if(kolone[0]==1) br[brojac]='1'; |
tim008 | 0:f32b917de198 | 32 | if(kolone[1]==1) br[brojac]='2'; |
tim008 | 0:f32b917de198 | 33 | if(kolone[2]==1) br[brojac]='3'; |
tim008 | 0:f32b917de198 | 34 | if(kolone[3]==1) op='+'; |
tim008 | 0:f32b917de198 | 35 | } |
tim008 | 0:f32b917de198 | 36 | else if(i==1){ |
tim008 | 0:f32b917de198 | 37 | if(kolone[0]==1) br[brojac]='4'; |
tim008 | 0:f32b917de198 | 38 | if(kolone[1]==1) br[brojac]='5'; |
tim008 | 0:f32b917de198 | 39 | if(kolone[2]==1) br[brojac]='6'; |
tim008 | 0:f32b917de198 | 40 | if(kolone[3]==1) op='-'; |
tim008 | 0:f32b917de198 | 41 | } |
tim008 | 0:f32b917de198 | 42 | else if(i==2){ |
tim008 | 0:f32b917de198 | 43 | if(kolone[0]==1) br[brojac]='7'; |
tim008 | 0:f32b917de198 | 44 | if(kolone[1]==1) br[brojac]='8'; |
tim008 | 0:f32b917de198 | 45 | if(kolone[2]==1) br[brojac]='9'; |
tim008 | 0:f32b917de198 | 46 | if(kolone[3]==1) op='/'; |
tim008 | 0:f32b917de198 | 47 | } |
tim008 | 0:f32b917de198 | 48 | else if(i==3){ |
tim008 | 0:f32b917de198 | 49 | if(kolone[0]==1) op='='; |
tim008 | 0:f32b917de198 | 50 | if(kolone[1]==1) br[brojac]='0'; |
tim008 | 0:f32b917de198 | 51 | if(kolone[2]==1) op=','; |
tim008 | 0:f32b917de198 | 52 | if(kolone[3]==1) op='*'; |
tim008 | 0:f32b917de198 | 53 | } |
tim008 | 0:f32b917de198 | 54 | |
tim008 | 0:f32b917de198 | 55 | redovi[i]=0; |
tim008 | 0:f32b917de198 | 56 | } |
tim008 | 0:f32b917de198 | 57 | brojac++; |
tim008 | 0:f32b917de198 | 58 | } |
tim008 | 0:f32b917de198 | 59 | |
tim008 | 0:f32b917de198 | 60 | } |
tim008 | 0:f32b917de198 | 61 | |
tim008 | 0:f32b917de198 | 62 | char taster2nd(){ |
tim008 | 0:f32b917de198 | 63 | int brojac=0; |
tim008 | 0:f32b917de198 | 64 | op = 'X'; |
tim008 | 0:f32b917de198 | 65 | while(brojac<2 || op != 'X'){ |
tim008 | 0:f32b917de198 | 66 | for(int i=0; i<4; i++){ |
tim008 | 0:f32b917de198 | 67 | redovi[i]=1; |
tim008 | 0:f32b917de198 | 68 | if(i==0){ |
tim008 | 0:f32b917de198 | 69 | if(kolone[0]==1) br[brojac]='1'; |
tim008 | 0:f32b917de198 | 70 | if(kolone[1]==1) br[brojac]='2'; |
tim008 | 0:f32b917de198 | 71 | if(kolone[2]==1) br[brojac]='3'; |
tim008 | 0:f32b917de198 | 72 | if(kolone[3]==1) op = 'S'; |
tim008 | 0:f32b917de198 | 73 | } |
tim008 | 0:f32b917de198 | 74 | else if(i==1){ |
tim008 | 0:f32b917de198 | 75 | if(kolone[0]==1) br[brojac]='4'; |
tim008 | 0:f32b917de198 | 76 | if(kolone[1]==1) br[brojac]='5'; |
tim008 | 0:f32b917de198 | 77 | if(kolone[2]==1) br[brojac]='6'; |
tim008 | 0:f32b917de198 | 78 | if(kolone[3]==1) op='>'; |
tim008 | 0:f32b917de198 | 79 | } |
tim008 | 0:f32b917de198 | 80 | else if(i==2){ |
tim008 | 0:f32b917de198 | 81 | if(kolone[0]==1) br[brojac]='7'; |
tim008 | 0:f32b917de198 | 82 | if(kolone[1]==1) br[brojac]='8'; |
tim008 | 0:f32b917de198 | 83 | if(kolone[2]==1) br[brojac]='9'; |
tim008 | 0:f32b917de198 | 84 | if(kolone[3]==1) op='<'; |
tim008 | 0:f32b917de198 | 85 | } |
tim008 | 0:f32b917de198 | 86 | else if(i==3){ |
tim008 | 0:f32b917de198 | 87 | if(kolone[0]==1) op='='; |
tim008 | 0:f32b917de198 | 88 | if(kolone[1]==1) br[brojac]='0'; |
tim008 | 0:f32b917de198 | 89 | if(kolone[2]==1) op='C'; |
tim008 | 0:f32b917de198 | 90 | if(kolone[3]==1) op='P'; |
tim008 | 0:f32b917de198 | 91 | } |
tim008 | 0:f32b917de198 | 92 | |
tim008 | 0:f32b917de198 | 93 | redovi[i]=0; |
tim008 | 0:f32b917de198 | 94 | } |
tim008 | 0:f32b917de198 | 95 | brojac++; |
tim008 | 0:f32b917de198 | 96 | } |
tim008 | 0:f32b917de198 | 97 | } |
tim008 | 0:f32b917de198 | 98 | |
tim008 | 0:f32b917de198 | 99 | char taster3rd(){ |
tim008 | 0:f32b917de198 | 100 | int brojac=0; |
tim008 | 0:f32b917de198 | 101 | op = 'X'; |
tim008 | 0:f32b917de198 | 102 | while(brojac<2 || op != 'X'){ |
tim008 | 0:f32b917de198 | 103 | for(int i=0; i<4; i++){ |
tim008 | 0:f32b917de198 | 104 | redovi[i]=1; |
tim008 | 0:f32b917de198 | 105 | if(i==0){ |
tim008 | 0:f32b917de198 | 106 | if(kolone[0]==1) br[brojac]='1'; |
tim008 | 0:f32b917de198 | 107 | if(kolone[1]==1) br[brojac]='2'; |
tim008 | 0:f32b917de198 | 108 | if(kolone[2]==1) br[brojac]='3'; |
tim008 | 0:f32b917de198 | 109 | if(kolone[3]==1) op = 'B'; |
tim008 | 0:f32b917de198 | 110 | } |
tim008 | 0:f32b917de198 | 111 | else if(i==1){ |
tim008 | 0:f32b917de198 | 112 | if(kolone[0]==1) br[brojac]='4'; |
tim008 | 0:f32b917de198 | 113 | if(kolone[1]==1) br[brojac]='5'; |
tim008 | 0:f32b917de198 | 114 | if(kolone[2]==1) br[brojac]='6'; |
tim008 | 0:f32b917de198 | 115 | if(kolone[3]==1) op = 'D'; |
tim008 | 0:f32b917de198 | 116 | } |
tim008 | 0:f32b917de198 | 117 | else if(i==2){ |
tim008 | 0:f32b917de198 | 118 | if(kolone[0]==1) br[brojac]='7'; |
tim008 | 0:f32b917de198 | 119 | if(kolone[1]==1) br[brojac]='8'; |
tim008 | 0:f32b917de198 | 120 | if(kolone[2]==1) br[brojac]='9'; |
tim008 | 0:f32b917de198 | 121 | if(kolone[3]==1) op = 'L'; |
tim008 | 0:f32b917de198 | 122 | } |
tim008 | 0:f32b917de198 | 123 | else if(i==3){ |
tim008 | 0:f32b917de198 | 124 | if(kolone[0]==1) op='='; |
tim008 | 0:f32b917de198 | 125 | if(kolone[1]==1) br[brojac]='0'; |
tim008 | 0:f32b917de198 | 126 | if(kolone[3]==1) op = 'I'; |
tim008 | 0:f32b917de198 | 127 | if(kolone[2]==1) op = 'T'; |
tim008 | 0:f32b917de198 | 128 | } |
tim008 | 0:f32b917de198 | 129 | |
tim008 | 0:f32b917de198 | 130 | redovi[i]=0; |
tim008 | 0:f32b917de198 | 131 | } |
tim008 | 0:f32b917de198 | 132 | brojac++; |
tim008 | 0:f32b917de198 | 133 | } |
tim008 | 0:f32b917de198 | 134 | } |
tim008 | 0:f32b917de198 | 135 | |
tim008 | 0:f32b917de198 | 136 | int BinToDec(int broj[]){ |
tim008 | 0:f32b917de198 | 137 | int sum=0; |
tim008 | 0:f32b917de198 | 138 | int vel = sizeof(broj)/sizeof(int); |
tim008 | 0:f32b917de198 | 139 | for(int i =0; i<vel; i++){ |
tim008 | 0:f32b917de198 | 140 | sum = sum+ pow((float)2,i); |
tim008 | 0:f32b917de198 | 141 | } |
tim008 | 0:f32b917de198 | 142 | return sum; |
tim008 | 0:f32b917de198 | 143 | } |
tim008 | 0:f32b917de198 | 144 | |
tim008 | 0:f32b917de198 | 145 | int dec_to_bin[2]; |
tim008 | 0:f32b917de198 | 146 | |
tim008 | 0:f32b917de198 | 147 | void DecToBin (int broj){ |
tim008 | 0:f32b917de198 | 148 | int i=0; |
tim008 | 0:f32b917de198 | 149 | while(broj>0 && broj<8){ |
tim008 | 0:f32b917de198 | 150 | if(broj%2 == 0) |
tim008 | 0:f32b917de198 | 151 | dec_to_bin[i] = 0; |
tim008 | 0:f32b917de198 | 152 | else dec_to_bin[i] = 1; |
tim008 | 0:f32b917de198 | 153 | i++; |
tim008 | 0:f32b917de198 | 154 | broj = broj/2; |
tim008 | 0:f32b917de198 | 155 | } |
tim008 | 0:f32b917de198 | 156 | |
tim008 | 0:f32b917de198 | 157 | } |
tim008 | 0:f32b917de198 | 158 | |
tim008 | 0:f32b917de198 | 159 | |
tim008 | 0:f32b917de198 | 160 | |
tim008 | 0:f32b917de198 | 161 | void show(char znak[]); |
tim008 | 0:f32b917de198 | 162 | void operacija(char znak){ |
tim008 | 0:f32b917de198 | 163 | int k = 0; |
tim008 | 0:f32b917de198 | 164 | int i = br[0] - '0' + (br[1] - '0')*10 + (br[2] - '0')*100; |
tim008 | 0:f32b917de198 | 165 | char slijedeci[3]; |
tim008 | 0:f32b917de198 | 166 | if(znak=='S' || znak=='<' || znak=='>' || znak=='C' || znak=='P') taster2nd(); |
tim008 | 0:f32b917de198 | 167 | else if(znak=='B' || znak=='D' || znak=='L' || znak=='I' || znak=='T') taster3rd(); |
tim008 | 0:f32b917de198 | 168 | else taster(); |
tim008 | 0:f32b917de198 | 169 | for(int i=0; i<3; i++) slijedeci[i] = br[i]; |
tim008 | 0:f32b917de198 | 170 | int j = slijedeci[0] - '0' + (slijedeci[1] - '0')*10 + (slijedeci[2] - '0')*100; |
tim008 | 0:f32b917de198 | 171 | |
tim008 | 0:f32b917de198 | 172 | if(znak == '+') { |
tim008 | 0:f32b917de198 | 173 | k = i+j; |
tim008 | 0:f32b917de198 | 174 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 175 | k/=100; |
tim008 | 0:f32b917de198 | 176 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 177 | k/=10; |
tim008 | 0:f32b917de198 | 178 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 179 | } |
tim008 | 0:f32b917de198 | 180 | if(znak == '-'){ |
tim008 | 0:f32b917de198 | 181 | k = i-j; |
tim008 | 0:f32b917de198 | 182 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 183 | k/=100; |
tim008 | 0:f32b917de198 | 184 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 185 | k/=10; |
tim008 | 0:f32b917de198 | 186 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 187 | } |
tim008 | 0:f32b917de198 | 188 | if(znak == '/') { |
tim008 | 0:f32b917de198 | 189 | k = (float)i/j; |
tim008 | 0:f32b917de198 | 190 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 191 | k/=100; |
tim008 | 0:f32b917de198 | 192 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 193 | k/=10; |
tim008 | 0:f32b917de198 | 194 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 195 | } |
tim008 | 0:f32b917de198 | 196 | if(znak == '*'){ |
tim008 | 0:f32b917de198 | 197 | k = i*j; |
tim008 | 0:f32b917de198 | 198 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 199 | k/=100; |
tim008 | 0:f32b917de198 | 200 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 201 | k/=10; |
tim008 | 0:f32b917de198 | 202 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 203 | } |
tim008 | 0:f32b917de198 | 204 | if(znak == ','){ |
tim008 | 0:f32b917de198 | 205 | k = i; |
tim008 | 0:f32b917de198 | 206 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 207 | k/=100; |
tim008 | 0:f32b917de198 | 208 | slijedeci[1] = '.'; |
tim008 | 0:f32b917de198 | 209 | k/=10; |
tim008 | 0:f32b917de198 | 210 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 211 | } |
tim008 | 0:f32b917de198 | 212 | |
tim008 | 0:f32b917de198 | 213 | //2nd operacije : korjen, spasi u memoriju, dobavi iz memorije, x na y, clear |
tim008 | 0:f32b917de198 | 214 | if(znak == 'S'){ |
tim008 | 0:f32b917de198 | 215 | k = sqrt(float(i)); |
tim008 | 0:f32b917de198 | 216 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 217 | k/=100; |
tim008 | 0:f32b917de198 | 218 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 219 | k/=10; |
tim008 | 0:f32b917de198 | 220 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 221 | } // korjen |
tim008 | 0:f32b917de198 | 222 | if(znak == 'C') { |
tim008 | 0:f32b917de198 | 223 | slijedeci[0] = ' '; |
tim008 | 0:f32b917de198 | 224 | slijedeci[1] = ' '; |
tim008 | 0:f32b917de198 | 225 | slijedeci[2] = '0'; |
tim008 | 0:f32b917de198 | 226 | } // clear |
tim008 | 0:f32b917de198 | 227 | if(znak == '>'){ |
tim008 | 0:f32b917de198 | 228 | memori = i; |
tim008 | 0:f32b917de198 | 229 | } // -> M tj. upis u memoriju |
tim008 | 0:f32b917de198 | 230 | if(znak == '<'){ |
tim008 | 0:f32b917de198 | 231 | k = memori; |
tim008 | 0:f32b917de198 | 232 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 233 | k/=100; |
tim008 | 0:f32b917de198 | 234 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 235 | k/=10; |
tim008 | 0:f32b917de198 | 236 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 237 | } // <- M tj. upis iz memorije |
tim008 | 0:f32b917de198 | 238 | if(znak == 'P'){ |
tim008 | 0:f32b917de198 | 239 | k = pow((float)i,j); |
tim008 | 0:f32b917de198 | 240 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 241 | k/=100; |
tim008 | 0:f32b917de198 | 242 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 243 | k/=10; |
tim008 | 0:f32b917de198 | 244 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 245 | } // x^y |
tim008 | 0:f32b917de198 | 246 | |
tim008 | 0:f32b917de198 | 247 | //3rd operacije: BinToDec, DecToBin, Ln, 1/x, sin |
tim008 | 0:f32b917de198 | 248 | if(znak == 'B'){ |
tim008 | 0:f32b917de198 | 249 | k = i*j; |
tim008 | 0:f32b917de198 | 250 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 251 | k/=100; |
tim008 | 0:f32b917de198 | 252 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 253 | k/=10; |
tim008 | 0:f32b917de198 | 254 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 255 | } // Binarni u dekadni |
tim008 | 0:f32b917de198 | 256 | if(znak == 'D'){{ |
tim008 | 0:f32b917de198 | 257 | k = i*j; |
tim008 | 0:f32b917de198 | 258 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 259 | k/=100; |
tim008 | 0:f32b917de198 | 260 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 261 | k/=10; |
tim008 | 0:f32b917de198 | 262 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 263 | } // Dekadni u binarni |
tim008 | 0:f32b917de198 | 264 | if(znak == 'L'){ |
tim008 | 0:f32b917de198 | 265 | k = log10(float(i)); |
tim008 | 0:f32b917de198 | 266 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 267 | k/=100; |
tim008 | 0:f32b917de198 | 268 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 269 | k/=10; |
tim008 | 0:f32b917de198 | 270 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 271 | } // ln(x) |
tim008 | 0:f32b917de198 | 272 | if(znak == 'I') { |
tim008 | 0:f32b917de198 | 273 | k = 1/float(i); |
tim008 | 0:f32b917de198 | 274 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 275 | k/=100; |
tim008 | 0:f32b917de198 | 276 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 277 | k/=10; |
tim008 | 0:f32b917de198 | 278 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 279 | } // 1/x |
tim008 | 0:f32b917de198 | 280 | if(znak == 'T') { |
tim008 | 0:f32b917de198 | 281 | k = sin(float(i)); |
tim008 | 0:f32b917de198 | 282 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 283 | k/=100; |
tim008 | 0:f32b917de198 | 284 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 285 | k/=10; |
tim008 | 0:f32b917de198 | 286 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 287 | } // sin(x) |
tim008 | 0:f32b917de198 | 288 | |
tim008 | 0:f32b917de198 | 289 | if(znak == '='){ |
tim008 | 0:f32b917de198 | 290 | k = i; |
tim008 | 0:f32b917de198 | 291 | slijedeci[0] = k%100 + '0'; |
tim008 | 0:f32b917de198 | 292 | k/=100; |
tim008 | 0:f32b917de198 | 293 | slijedeci[1] = k%10 + '0'; |
tim008 | 0:f32b917de198 | 294 | k/=10; |
tim008 | 0:f32b917de198 | 295 | slijedeci[2] = k + '0'; |
tim008 | 0:f32b917de198 | 296 | } |
tim008 | 0:f32b917de198 | 297 | show(slijedeci); |
tim008 | 0:f32b917de198 | 298 | } |
tim008 | 0:f32b917de198 | 299 | } |
tim008 | 0:f32b917de198 | 300 | |
tim008 | 0:f32b917de198 | 301 | void show(char znak[]){ |
tim008 | 0:f32b917de198 | 302 | for(int i=0; i<3; i++){ |
tim008 | 0:f32b917de198 | 303 | |
tim008 | 0:f32b917de198 | 304 | if(znak[i]>='0' && znak[i]<='9') |
tim008 | 0:f32b917de198 | 305 | { |
tim008 | 0:f32b917de198 | 306 | ekran = brojevi[znak[i] - '0']; |
tim008 | 0:f32b917de198 | 307 | } |
tim008 | 0:f32b917de198 | 308 | |
tim008 | 0:f32b917de198 | 309 | else |
tim008 | 0:f32b917de198 | 310 | { |
tim008 | 0:f32b917de198 | 311 | operacija(znak[i]); |
tim008 | 0:f32b917de198 | 312 | |
tim008 | 0:f32b917de198 | 313 | } |
tim008 | 0:f32b917de198 | 314 | } |
tim008 | 0:f32b917de198 | 315 | |
tim008 | 0:f32b917de198 | 316 | } |
tim008 | 0:f32b917de198 | 317 | |
tim008 | 0:f32b917de198 | 318 | |
tim008 | 0:f32b917de198 | 319 | int main() { |
tim008 | 0:f32b917de198 | 320 | enable = 1; |
tim008 | 0:f32b917de198 | 321 | int t1=1, t2=1; |
tim008 | 0:f32b917de198 | 322 | char pom[2]; |
tim008 | 0:f32b917de198 | 323 | |
tim008 | 0:f32b917de198 | 324 | while(1) { |
tim008 | 0:f32b917de198 | 325 | if(taster1){ |
tim008 | 0:f32b917de198 | 326 | if(t1==1) t1=0; |
tim008 | 0:f32b917de198 | 327 | else t1=1; |
tim008 | 0:f32b917de198 | 328 | } |
tim008 | 0:f32b917de198 | 329 | if(taster2){ |
tim008 | 0:f32b917de198 | 330 | if(t1==1) t1=0; |
tim008 | 0:f32b917de198 | 331 | else t1=1; |
tim008 | 0:f32b917de198 | 332 | } |
tim008 | 0:f32b917de198 | 333 | if((t1==0 && t2==0) || t1==0) taster2nd(); |
tim008 | 0:f32b917de198 | 334 | else if(t2==0) taster3rd(); |
tim008 | 0:f32b917de198 | 335 | else taster(); |
tim008 | 0:f32b917de198 | 336 | for(int i = 0; i<3; i++) pom[i] = br[i]; |
tim008 | 0:f32b917de198 | 337 | show(pom); |
tim008 | 0:f32b917de198 | 338 | } |
tim008 | 0:f32b917de198 | 339 | } |