Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * main.c
- *
- * Created on: 10.2.2012
- * Author: Morphe
- */
- #include <stdlib.h>
- #include <stdio.h>
- #include <locale.h>
- char *numbers[] = {
- "ноль", "один", "дв", "три", "четыр", "пят", "шест", "сем", "восем",
- "девят", "ьдесят", "енадцать", "сорок", "девяносто"
- }, *minus="минус";
- char *getBody(int x) {
- if(x>=20) {
- x/=10;
- if(x==4) return numbers[12];
- else if(x==9) return numbers[13];
- }
- else if(x>10) x-=10;
- else if(x==10) return numbers[10]+1;
- return numbers[x];
- }
- char *getSuffix(int x) {
- if(x>=90)
- return "";
- else if(x>=50)
- return numbers[10]+(x/10==7 ? 1 : 0);
- else if(x>=40)
- return "";
- else if(x>=30)
- return numbers[11]+3;
- else if(x>=20)
- return numbers[11]+2;
- else if(x>11)
- return numbers[11]+(x>12?1:0);
- else if(x>=5)
- return "ь";
- switch (x) {
- case 2:
- return "a";
- case 4:
- return "е";
- default:
- break;
- }
- return "";
- }
- int main() {
- int x;
- setlocale(LC_ALL, "Russian");
- while(1) {
- scanf("%d", &x);
- printf("%s%s", getBody(x), getSuffix(x));
- if(x>=20) {
- x%=10;
- if(x!=0) printf(" %s%s", getBody(x), getSuffix(x));
- }
- putchar('\n');
- system("pause");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment