Advertisement
Guest User

Untitled

a guest
May 7th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows>
  3. #include <conio>
  4. #include <locale>
  5.  
  6. #include <stdlib>
  7. //#include <alloc>
  8. #include <cstring>
  9. //#include <stdio>
  10.  
  11. struct nm
  12. {
  13. int num;
  14. int e;
  15. int d;
  16. int s;
  17. };
  18.  
  19. void propis(struct nm &nn);
  20. char* PrintLine (struct nm &nn, char *ll);
  21.  
  22. void main (void)
  23. {
  24. setlocale(LC_ALL, "Russian");
  25. SetConsoleOutputCP(1251);
  26. SetConsoleCP(1251);
  27. setlocale(LC_CTYPE, "rus");
  28.  
  29. system("color 0F");
  30.  
  31. nm nnn; char Line1[1000];
  32.  
  33. cout<<"Введите число = "; cin>> nnn.num; strcpy(Line1," ");
  34.  
  35. propis(nnn); PrintLine(nnn,Line1);
  36.  
  37. cout<<"Прописью будет..."<<Line1<<endl<<endl;
  38.  
  39. system("pause");
  40. //getch();
  41. return;
  42.  
  43. }
  44. //////////////////////////////// Contents number ////////////////////
  45.  
  46. void propis(struct nm &nn)
  47. {
  48. int x= nn.num;
  49. if (x<0) { x*=-1; }
  50. if ( x==0 ) { nn.e=0; nn.d=0; nn.s=0; return; }
  51. nn.e= x%10;
  52. x=x/10;
  53. nn.d= x%10;
  54. x= x/10;
  55. nn.s= x%10;
  56. return;
  57. }
  58.  
  59. ///////////////////////////////////////////// Characters number ////////////
  60.  
  61. char* PrintLine (struct nm &nn, char *ll)
  62. {
  63. string ed[10]= {" ","Один","Два","Три","Четыре","Пять","Шесть","Семь","Восемь","Девять"};
  64. string sto[10]= {" ","Сто","Двести","Триста","Четыреста","Пятьсот","Шестьсот","Семьсот","Восемьсот","Девятьсот"};
  65. string des[10]= {" ","Одиннадцать","Двенадцать","Тринадцать","Четырнадцать","Пятнадцать","Шестнадцать","Семнадцать","Восемнадцать","Девятнадцать"};
  66. string dc[10]= {" ","Десять","Двадцать","Тридцать","Сорок","Пятьдесят","Шестьдесят","Семьдесят","Восемьдесят","Девяносто"};
  67.  
  68. if (nn.num<0) strcat(ll,"Минус ");
  69. if ( nn.num==0 ) { strcpy(ll,"Ноль"); return ll; }
  70. string ss; int index;
  71.  
  72. index= nn.s; // Сотни
  73. ss= sto[index]; strcat(ll, ss.c_str()); strcat(ll," ");
  74.  
  75. index= nn.d; // Десятки
  76. if (index==1)
  77. { index= nn.e; ss= des[index]; strcat(ll, ss.c_str()); strcat(ll," "); return ll; }
  78. else ss= dc[index];
  79. strcat(ll, ss.c_str()); strcat(ll," ");
  80.  
  81. index= nn.e; // Единицы
  82. ss= ed[index]; strcat(ll, ss.c_str()); strcat(ll," ");
  83. return ll;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement