Created
October 24, 2009 17:08
-
-
Save farcaller/217628 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <math.h> | |
| int main (int argc, const char *argv[]) | |
| { | |
| int chislo, one, two, three, i, tet; | |
| int size = 0; | |
| for (tet = 10; tet < 999; tet++) { | |
| int yes = yesNo(tet); | |
| } | |
| return 0; | |
| } | |
| int power(int test, int size) | |
| { | |
| int res=1; | |
| while(size) { | |
| if (size&1) | |
| res *= test; | |
| test *= test; | |
| size >>=1;; | |
| } | |
| return res; | |
| } | |
| int yesNo(int one) | |
| { | |
| int i = 0; | |
| int size = 0; // <--- fcuk here | |
| unsigned b = one; | |
| int nachalo = one; | |
| b = one; | |
| do { | |
| b /= 10; | |
| ++size; | |
| } while(b>0); | |
| int c[size]; | |
| int summa=0; | |
| for (i = 0; i<size; ++i) { | |
| c[i] = one%10; | |
| one /= 10; | |
| int test =c[i]; | |
| int print = power(test, size); | |
| summa += print; | |
| } | |
| int yesno =0; | |
| if (summa == nachalo) | |
| printf("Есть Армстронга %i\n",nachalo); | |
| else | |
| printf("Не Армстронга\n"); | |
| return yesno; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment