r6
| 1 | ##@미완성. 아마 작성된다면 수만 자는 나올 지도. 본 문서는 {{{틀}}} 네임스페이스의 편집 ACL에 맞게, 인증된 사용자이면 편집할 수 있습니다. |
|---|
r1
| 2 | ##@[include(틀:문서 가져옴/the seed, 위키=t, 문서명=틀:계산기, 버전=28, uuid=6259b383-901a-449b-b75c-5106a5c865ac)] |
|---|
r4
| 3 | ##테스트용 if문. 식="텍스트" 형식으로 입력하고 미리보기 가능. |
|---|
r5
| 4 | {{{#!if |
|---|
r3
| 5 | }}}{{{#!if b=(식==null)||(식==""), b |
|---|
r1
| 6 | ##b : blank |
|---|
r2
| 7 | 식을 입력하세요... (숫자와 {{{+}}}, {{{-}}}, {{{*}}}, {{{/}}}만 입력 가능합니다.)}}}{{{#!wiki style="display: none;" |
|---|
r4
| 8 | ##d : 자릿수, r : read |
|---|
| 9 | {{{#!if l=식.length, d=0, r=1 |
|---|
r2
| 10 | }}}}}}{{{#!if !b |
|---|
r3
| 11 | ##print와 for문이 없으면 이렇게 환장할 수 있는 길이가 나옵니다. |
|---|
| 12 | {{{#!wiki style="display: inline-flex;" |
|---|
| 13 | {{{#!wiki style="display: inline-block; width: .8em; height: 1.5em; padding: 0 0.1em; margin: 0 0.05em; background: #abcdef; text-align: center;" |
|---|
| 14 | {{{#!if d<l |
|---|
| 15 | {{{#!if 식[d]==48 |
|---|
r4
| 16 | {{{#!if this['r'+d]=1 |
|---|
| 17 | }}}0}}}{{{#!if 식[d]==49 |
|---|
| 18 | {{{#!if this['r'+d]=1 |
|---|
| 19 | }}}1}}}{{{#!if 식[d]==50 |
|---|
| 20 | {{{#!if this['r'+d]=1 |
|---|
| 21 | }}}2}}}{{{#!if 식[d]==51 |
|---|
| 22 | {{{#!if this['r'+d]=1 |
|---|
| 23 | }}}3}}}{{{#!if 식[d]==52 |
|---|
| 24 | {{{#!if this['r'+d]=1 |
|---|
| 25 | }}}4}}}{{{#!if 식[d]==53 |
|---|
| 26 | {{{#!if this['r'+d]=1 |
|---|
| 27 | }}}5}}}{{{#!if 식[d]==54 |
|---|
| 28 | {{{#!if this['r'+d]=1 |
|---|
| 29 | }}}6}}}{{{#!if 식[d]==55 |
|---|
| 30 | {{{#!if this['r'+d]=1 |
|---|
| 31 | }}}7}}}{{{#!if 식[d]==56 |
|---|
| 32 | {{{#!if this['r'+d]=1 |
|---|
| 33 | }}}8}}}{{{#!if 식[d]==57 |
|---|
| 34 | {{{#!if this['r'+d]=1 |
|---|
| 35 | }}}9}}}{{{#!if d=d+1 |
|---|
r7
| 36 | }}}}}}}}}{{{#!wiki style="display: inline-block; width: .8em; height: 1.5em; padding: 0 0.1em; margin: 0 0.05em; background: #abcdef; text-align: center" |
|---|
r3
| 37 | {{{#!if d<l |
|---|
| 38 | {{{#!if 식[d]==48 |
|---|
| 39 | 0}}}{{{#!if 식[d]==49 |
|---|
| 40 | 1}}}{{{#!if 식[d]==50 |
|---|
| 41 | 2}}}{{{#!if 식[d]==51 |
|---|
| 42 | 3}}}{{{#!if 식[d]==52 |
|---|
| 43 | 4}}}{{{#!if 식[d]==53 |
|---|
| 44 | 5}}}{{{#!if 식[d]==54 |
|---|
| 45 | 6}}}{{{#!if 식[d]==55 |
|---|
| 46 | 7}}}{{{#!if 식[d]==56 |
|---|
| 47 | 8}}}{{{#!if 식[d]==57 |
|---|
| 48 | 9}}}{{{#!if d=d+1 |
|---|
r8
| 49 | }}}}}}}}}}}}}}} |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | == 테스트 == |
|---|
| 53 | {{{#!if 식="3.141592" |
|---|
| 54 | 식="3.141592"}}}{{{#!if s1=false, s2=false, s3=false, j=1+0, i=0+0, k=1+0 |
|---|
r9
| 55 | }}} |
|---|
| 56 | 초기화 불러오기. |
|---|
| 57 | |
|---|
| 58 | {{{#!if this['d'+i] = (식[i]>=48&&식[i]<=57) |
|---|
r8
| 59 | }}}{{{#!if (s1==false)&&this['d'+i]&&(s3==false) |
|---|
| 60 | {{{#!if this['v'+j] = +(식.substr(i,1)), s1=true, s3=true |
|---|
| 61 | }}}}}}{{{#!if (s1==true)&&this['d'+i]&&(s3==false) |
|---|
| 62 | {{{#!if s2==false |
|---|
| 63 | {{{#!if this['v'+j] = 10*this['v'+j]+(+(식.substr(i,1))), s3=true |
|---|
| 64 | }}}}}}{{{#!if s2==true |
|---|
| 65 | {{{#!if this['v'+j] = this['v'+j]+(10.0**(-k))*(+(식.substr(i,1))), s3=true |
|---|
| 66 | }}}{{{#!if k+=1 |
|---|
r9
| 67 | }}}}}}}}}{{{#!if (s1==true)&&(s2==false)&&(식[i]==46)&&(s3==false) |
|---|
r8
| 68 | {{{#!if s2=true, s3=true, k=1+0 |
|---|
r10
| 69 | }}}}}}{{{#!if (s1==true)&&(((s2==false)&&!this['d'+i]&&(식[i]!=46)||(s2==false))||((s2==true)&&!this['d'+i]&&(식=[i]==46)))&&(s3==false) |
|---|
r8
| 70 | {{{#!if j+=1, s1=false, s2=false, s3=true |
|---|
| 71 | }}}{{{#!if s3==true |
|---|
| 72 | {{{#!if s3=false |
|---|
| 73 | }}}}}} |
|---|
| 74 | }}}{{{#!if i+=1 |
|---|
| 75 | }}} |
|---|
| 76 | |
|---|
r9
| 77 | 검사 |
|---|
r8
| 78 | {{{#!if v1==3 |
|---|
| 79 | v1==3}}} |
|---|
| 80 | ---- |
|---|
| 81 | {{{#!if this['d'+i] = (식[i]>=48&&식[i]<=57) |
|---|
| 82 | }}}{{{#!if (s1==false)&&this['d'+i]&&(s3==false) |
|---|
| 83 | {{{#!if this['v'+j] = +(식.substr(i,1)), s1=true, s3=true |
|---|
| 84 | }}}}}}{{{#!if (s1==true)&&this['d'+i]&&(s3==false) |
|---|
| 85 | {{{#!if s2==false |
|---|
| 86 | {{{#!if this['v'+j] = 10*this['v'+j]+(+(식.substr(i,1))), s3=true |
|---|
| 87 | }}}}}}{{{#!if s2==true |
|---|
| 88 | {{{#!if this['v'+j] = this['v'+j]+(10.0**(-k))*(+(식.substr(i,1))), s3=true |
|---|
| 89 | }}}{{{#!if k+=1 |
|---|
r14
| 90 | }}}}}}}}}{{{#!if (s1==true)&&(this.s2==false)&&(식[i]==46)&&(s3==false) |
|---|
| 91 | {{{#!if this.s2=true, s3=true, k=1+0 |
|---|
r10
| 92 | }}}}}}{{{#!if (s1==true)&&(((s2==false)&&!this['d'+i]&&(식[i]!=46)||(s2==false))||((s2==true)&&!this['d'+i]&&(식=[i]==46)))&&(s3==false) |
|---|
r8
| 93 | {{{#!if j+=1, s1=false, s2=false, s3=true |
|---|
| 94 | }}}{{{#!if s3==true |
|---|
| 95 | {{{#!if s3=false |
|---|
| 96 | }}}}}} |
|---|
| 97 | }}} |
|---|
r11
| 98 | 검사1 |
|---|
| 99 | {{{#!if 식[i]==46 |
|---|
| 100 | 식[i]==46}}} |
|---|
r14
| 101 | {{{#!if s1==true |
|---|
| 102 | s1==true}}} |
|---|
r12
| 103 | {{{#!if s2==true |
|---|
| 104 | s2==true}}} |
|---|
r15
| 105 | {{{if s2==false |
|---|
| 106 | s2==false}}} |
|---|
r11
| 107 | {{{#!if i+=1 |
|---|
| 108 | }}} |
|---|
r9
| 109 | |
|---|
r11
| 110 | 검사2 |
|---|
r8
| 111 | {{{#!if v1==3 |
|---|
| 112 | v1==3}}} |
|---|
r9
| 113 | {{{#!if j==1 |
|---|
| 114 | j==1}}} |
|---|
r11
| 115 | |
|---|
r8
| 116 | ---- |
|---|
| 117 | {{{#!if this['d'+i] = (식[i]>=48&&식[i]<=57) |
|---|
| 118 | }}}{{{#!if (s1==false)&&this['d'+i]&&(s3==false) |
|---|
| 119 | {{{#!if this['v'+j] = +(식.substr(i,1)), s1=true, s3=true |
|---|
| 120 | }}}}}}{{{#!if (s1==true)&&this['d'+i]&&(s3==false) |
|---|
| 121 | {{{#!if s2==false |
|---|
| 122 | {{{#!if this['v'+j] = 10*this['v'+j]+(+(식.substr(i,1))), s3=true |
|---|
| 123 | }}}}}}{{{#!if s2==true |
|---|
| 124 | {{{#!if this['v'+j] = this['v'+j]+(10.0**(-k))*(+(식.substr(i,1))), s3=true |
|---|
| 125 | }}}{{{#!if k+=1 |
|---|
r9
| 126 | }}}}}}}}}{{{#!if (s1==true)&&(s2==false)&&(식[i]==46)&&(s3==false) |
|---|
r8
| 127 | {{{#!if s2=true, s3=true, k=1+0 |
|---|
r10
| 128 | }}}}}}{{{#!if (s1==true)&&(((s2==false)&&!this['d'+i]&&(식[i]!=46)||(s2==false))||((s2==true)&&!this['d'+i]&&(식=[i]==46)))&&(s3==false) |
|---|
r8
| 129 | {{{#!if j+=1, s1=false, s2=false, s3=true |
|---|
| 130 | }}}{{{#!if s3==true |
|---|
| 131 | {{{#!if s3=false |
|---|
| 132 | }}}}}} |
|---|
| 133 | }}} |
|---|
r9
| 134 | 검사 (i=+1을 뒤로 넘김) |
|---|
r8
| 135 | {{{#!if v1==3 |
|---|
| 136 | v1==3}}} |
|---|
r10
| 137 | {{{#!if s2==true |
|---|
| 138 | s2==true}}} |
|---|
r8
| 139 | {{{#!if k==1 |
|---|
| 140 | k==1}}} |
|---|
| 141 | {{{#!if 10.0**(-k)==0.1 |
|---|
| 142 | 10**(-k)==10**(-1)==0.1}}} |
|---|
| 143 | {{{#!if i==2 |
|---|
| 144 | i==2}}} |
|---|
| 145 | {{{#!if +(식.substr(i,1))==1 |
|---|
| 146 | +(식.substr(i,1))==1}}} |
|---|
r9
| 147 | {{{#!if +(10.0**(-k))*(+(식.substr(i,1)))==0.1 |
|---|
| 148 | +(10.0**(-k))*(+(식.substr(i,1)))==0.1}}} |
|---|
r8
| 149 | |
|---|
r10
| 150 | {{{#!if this['v'+j]==3 |
|---|
| 151 | this['v'+j]==3}}} |
|---|
| 152 | |
|---|
r9
| 153 | {{{#!if this['v'+j]+(10.0**(-k))*(+(식.substr(i,1)))==3.1 |
|---|
| 154 | 3.1}}} |
|---|
| 155 | |
|---|
r10
| 156 | {{{#!if this['v'+j] = this['v'+j]+(10.0**(-k))*(+(식.substr(i,1))) |
|---|
| 157 | }}} |
|---|
r13
| 158 | 강제로 집어넣으면 입력은 된다. |
|---|
r9
| 159 | {{{#!if v1==3.1 |
|---|
| 160 | v1==3.1}}} |
|---|
| 161 | |
|---|
r8
| 162 | {{{#!if i+=1 |
|---|
| 163 | }}} |
|---|
| 164 | ---- |
|---|
| 165 | {{{#!if this['d'+i] = (식[i]>=48&&식[i]<=57) |
|---|
| 166 | }}}{{{#!if (s1==false)&&this['d'+i]&&(s3==false) |
|---|
| 167 | {{{#!if this['v'+j] = +(식.substr(i,1)), s1=true, s3=true |
|---|
| 168 | }}}}}}{{{#!if (s1==true)&&this['d'+i]&&(s3==false) |
|---|
| 169 | {{{#!if s2==false |
|---|
| 170 | {{{#!if this['v'+j] = 10*this['v'+j]+(+(식.substr(i,1))), s3=true |
|---|
| 171 | }}}}}}{{{#!if s2==true |
|---|
| 172 | {{{#!if this['v'+j] = this['v'+j]+(10.0**(-k))*(+(식.substr(i,1))), s3=true |
|---|
| 173 | }}}{{{#!if k+=1 |
|---|
| 174 | }}}}}}}}}{{{#!if (s1==true)&&(식[i]==46)&&(s3==false) |
|---|
| 175 | {{{#!if s2=true, s3=true, k=1+0 |
|---|
| 176 | }}}}}}{{{#!if (s1==true)&&!this['d'+i]&&(s3==false) |
|---|
| 177 | {{{#!if j+=1, s1=false, s2=false, s3=true |
|---|
| 178 | }}}{{{#!if s3==true |
|---|
| 179 | {{{#!if s3=false |
|---|
| 180 | }}}}}} |
|---|
| 181 | }}}{{{#!if i+=1 |
|---|
| 182 | }}}{{{#!if this['d'+i] = (식[i]>=48&&식[i]<=57) |
|---|
| 183 | }}}{{{#!if (s1==false)&&this['d'+i]&&(s3==false) |
|---|
| 184 | {{{#!if this['v'+j] = +(식.substr(i,1)), s1=true, s3=true |
|---|
| 185 | }}}}}}{{{#!if (s1==true)&&this['d'+i]&&(s3==false) |
|---|
| 186 | {{{#!if s2==false |
|---|
| 187 | {{{#!if this['v'+j] = 10*this['v'+j]+(+(식.substr(i,1))), s3=true |
|---|
| 188 | }}}}}}{{{#!if s2==true |
|---|
| 189 | {{{#!if this['v'+j] = this['v'+j]+(10.0**(-k))*(+(식.substr(i,1))), s3=true |
|---|
| 190 | }}}{{{#!if k+=1 |
|---|
| 191 | }}}}}}}}}{{{#!if (s1==true)&&(식[i]==46)&&(s3==false) |
|---|
| 192 | {{{#!if s2=true, s3=true, k=1+0 |
|---|
| 193 | }}}}}}{{{#!if (s1==true)&&!this['d'+i]&&(s3==false) |
|---|
| 194 | {{{#!if j+=1, s1=false, s2=false, s3=true |
|---|
| 195 | }}}{{{#!if s3==true |
|---|
| 196 | {{{#!if s3=false |
|---|
| 197 | }}}}}} |
|---|
| 198 | }}}{{{#!if i+=1 |
|---|
| 199 | }}}{{{#!if this['d'+i] = (식[i]>=48&&식[i]<=57) |
|---|
| 200 | }}}{{{#!if (s1==false)&&this['d'+i]&&(s3==false) |
|---|
| 201 | {{{#!if this['v'+j] = +(식.substr(i,1)), s1=true, s3=true |
|---|
| 202 | }}}}}}{{{#!if (s1==true)&&this['d'+i]&&(s3==false) |
|---|
| 203 | {{{#!if s2==false |
|---|
| 204 | {{{#!if this['v'+j] = 10*this['v'+j]+(+(식.substr(i,1))), s3=true |
|---|
| 205 | }}}}}}{{{#!if s2==true |
|---|
| 206 | {{{#!if this['v'+j] = this['v'+j]+(10.0**(-k))*(+(식.substr(i,1))), s3=true |
|---|
| 207 | }}}{{{#!if k+=1 |
|---|
| 208 | }}}}}}}}}{{{#!if (s1==true)&&(식[i]==46)&&(s3==false) |
|---|
| 209 | {{{#!if s2=true, s3=true, k=1+0 |
|---|
| 210 | }}}}}}{{{#!if (s1==true)&&!this['d'+i]&&(s3==false) |
|---|
| 211 | {{{#!if j+=1, s1=false, s2=false, s3=true |
|---|
| 212 | }}}{{{#!if s3==true |
|---|
| 213 | {{{#!if s3=false |
|---|
| 214 | }}}}}} |
|---|
| 215 | }}}{{{#!if i+=1 |
|---|
| 216 | }}} |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | {{{#!if v1=="3.1415" |
|---|
| 220 | v1=="3.1415"}}} |
|---|
| 221 | {{{#!if v1=="3.14159" |
|---|
| 222 | v1=="3.14159"}}} |
|---|
| 223 | |
|---|
| 224 | {{{#!if this['d'+i] = (식[i]>=48&&식[i]<=57) |
|---|
| 225 | }}}{{{#!if (s1==false)&&this['d'+i]&&(s3==false) |
|---|
| 226 | {{{#!if this['v'+j] = +(식.substr(i,1)), s1=true, s3=true |
|---|
| 227 | }}}}}}{{{#!if (s1==true)&&this['d'+i]&&(s3==false) |
|---|
| 228 | {{{#!if s2==false |
|---|
| 229 | {{{#!if this['v'+j] = 10*this['v'+j]+(+(식.substr(i,1))), s3=true |
|---|
| 230 | }}}}}}{{{#!if s2==true |
|---|
| 231 | {{{#!if this['v'+j] = this['v'+j]+(10.0**(-k))*(+(식.substr(i,1))), s3=true |
|---|
| 232 | }}}{{{#!if k+=1 |
|---|
| 233 | }}}}}}}}}{{{#!if (s1==true)&&(식[i]==46)&&(s3==false) |
|---|
| 234 | {{{#!if s2=true, s3=true, k=1+0 |
|---|
| 235 | }}}}}}{{{#!if (s1==true)&&!this['d'+i]&&(s3==false) |
|---|
| 236 | {{{#!if j+=1, s1=false, s2=false, s3=true |
|---|
| 237 | }}}{{{#!if s3==true |
|---|
| 238 | {{{#!if s3=false |
|---|
| 239 | }}}}}} |
|---|
| 240 | }}}{{{#!if i+=1 |
|---|
| 241 | }}} |
|---|
| 242 | |
|---|
| 243 | {{{#!if v1=="3.14159" |
|---|
| 244 | v1=="3.14159"}}} |
|---|
| 245 | |
|---|
| 246 | {{{#!if this['d'+i] = (식[i]>=48&&식[i]<=57) |
|---|
| 247 | }}}{{{#!if (s1==false)&&this['d'+i]&&(s3==false) |
|---|
| 248 | {{{#!if this['v'+j] = +(식.substr(i,1)), s1=true, s3=true |
|---|
| 249 | }}}}}}{{{#!if (s1==true)&&this['d'+i]&&(s3==false) |
|---|
| 250 | {{{#!if s2==false |
|---|
| 251 | {{{#!if this['v'+j] = 10*this['v'+j]+(+(식.substr(i,1))), s3=true |
|---|
| 252 | }}}}}}{{{#!if s2==true |
|---|
| 253 | {{{#!if this['v'+j] = this['v'+j]+(10.0**(-k))*(+(식.substr(i,1))), s3=true |
|---|
| 254 | }}}{{{#!if k+=1 |
|---|
| 255 | }}}}}}}}}{{{#!if (s1==true)&&(식[i]==46)&&(s3==false) |
|---|
| 256 | {{{#!if s2=true, s3=true, k=1+0 |
|---|
| 257 | }}}}}}{{{#!if (s1==true)&&!this['d'+i]&&(s3==false) |
|---|
| 258 | {{{#!if j+=1, s1=false, s2=false, s3=true |
|---|
| 259 | }}}{{{#!if s3==true |
|---|
| 260 | {{{#!if s3=false |
|---|
| 261 | }}}}}} |
|---|
| 262 | }}}{{{#!if i+=1 |
|---|
| 263 | }}} |
|---|
| 264 | {{{#!if v1=="3.141592" |
|---|
| 265 | v1=="3.141592"}}} |
|---|