Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- typedef struct
- {
- int numbers[20];
- int tens[10];
- int hundred;
- int thousand;
- int and;
- } Size;
- Size size =
- {
- {0,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8},
- {0,0,6,6,5,5,5,7,6,6},
- 7,
- 8,
- 3
- };
- int main()
- {
- int i, acc = 0;
- for (i=1; i<=1000; i++)
- {
- if (i == 1000)
- acc += size.numbers[1] + size.thousand;
- else if (i >= 100)
- acc += size.numbers[i/100] + size.hundred + (i%100!=0?size.and:0);
- acc += size.tens[(i/10)%10];
- acc += size.numbers[(i%100>=20)?i%10:i%100];
- }
- printf("%d\n",acc);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement