Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows>
- #include <conio>
- #include <locale>
- #include <stdlib>
- //#include <alloc>
- #include <cstring>
- //#include <stdio>
- struct nm
- {
- int num;
- int e;
- int d;
- int s;
- };
- void propis(struct nm &nn);
- char* PrintLine (struct nm &nn, char *ll);
- void main (void)
- {
- setlocale(LC_ALL, "Russian");
- SetConsoleOutputCP(1251);
- SetConsoleCP(1251);
- setlocale(LC_CTYPE, "rus");
- system("color 0F");
- nm nnn; char Line1[1000];
- cout<<"Введите число = "; cin>> nnn.num; strcpy(Line1," ");
- propis(nnn); PrintLine(nnn,Line1);
- cout<<"Прописью будет..."<<Line1<<endl<<endl;
- system("pause");
- //getch();
- return;
- }
- //////////////////////////////// Contents number ////////////////////
- void propis(struct nm &nn)
- {
- int x= nn.num;
- if (x<0) { x*=-1; }
- if ( x==0 ) { nn.e=0; nn.d=0; nn.s=0; return; }
- nn.e= x%10;
- x=x/10;
- nn.d= x%10;
- x= x/10;
- nn.s= x%10;
- return;
- }
- ///////////////////////////////////////////// Characters number ////////////
- char* PrintLine (struct nm &nn, char *ll)
- {
- string ed[10]= {" ","Один","Два","Три","Четыре","Пять","Шесть","Семь","Восемь","Девять"};
- string sto[10]= {" ","Сто","Двести","Триста","Четыреста","Пятьсот","Шестьсот","Семьсот","Восемьсот","Девятьсот"};
- string des[10]= {" ","Одиннадцать","Двенадцать","Тринадцать","Четырнадцать","Пятнадцать","Шестнадцать","Семнадцать","Восемнадцать","Девятнадцать"};
- string dc[10]= {" ","Десять","Двадцать","Тридцать","Сорок","Пятьдесят","Шестьдесят","Семьдесят","Восемьдесят","Девяносто"};
- if (nn.num<0) strcat(ll,"Минус ");
- if ( nn.num==0 ) { strcpy(ll,"Ноль"); return ll; }
- string ss; int index;
- index= nn.s; // Сотни
- ss= sto[index]; strcat(ll, ss.c_str()); strcat(ll," ");
- index= nn.d; // Десятки
- if (index==1)
- { index= nn.e; ss= des[index]; strcat(ll, ss.c_str()); strcat(ll," "); return ll; }
- else ss= dc[index];
- strcat(ll, ss.c_str()); strcat(ll," ");
- index= nn.e; // Единицы
- ss= ed[index]; strcat(ll, ss.c_str()); strcat(ll," ");
- return ll;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement