Advertisement
asmodeus94

intNaString

Mar 9th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <cstdlib>
  4. #include <string>
  5. #include <sstream>
  6. using namespace std;
  7. string tab[10001];
  8. string liczbS[4];
  9. int zeraP(int ilZ){
  10. int z=1;
  11.     for(int s=0;s<ilZ;s++){
  12.         z*=10;
  13.     }
  14. return z;
  15. }
  16. int main(){
  17. tab[1]="jeden";
  18. tab[2]="dwa";
  19. tab[3]="trzy";
  20. tab[4]="cztery";
  21. tab[5]="piec";
  22. tab[6]="szesc";
  23. tab[7]="siedem";
  24. tab[8]="osiem";
  25. tab[9]="dziewiec";
  26. tab[11]="jedenascie";
  27. tab[12]="dwanascie";
  28. tab[13]="trzynascie";
  29. tab[14]="czternascie";
  30. tab[15]="pietnascie";
  31. tab[16]="szesnascie";
  32. tab[17]="siedemnascie";
  33. tab[18]="osiemnascie";
  34. tab[19]="dziewietnascie";
  35. tab[10]="dziesiec";
  36. tab[20]="dwadziescia";
  37. tab[30]="trzydziesci";
  38. tab[40]="czterdziesci";
  39. tab[50]="piecdziesiat";
  40. tab[60]="szescdziesiat";
  41. tab[70]="siedemdziesiat";
  42. tab[80]="osiemdziesiat";
  43. tab[90]="dziewiecdziesiat";
  44. tab[100]="sto";
  45. tab[200]="dwiescie";
  46. tab[300]="trzysta";
  47. tab[400]="czterysta";
  48. tab[500]="piecset";
  49. tab[600]="szescset";
  50. tab[700]="siedemset";
  51. tab[800]="osiemset";
  52. tab[900]="dziewiecset";
  53. tab[1000]="tysiac";
  54. tab[2000]="dwa tysiace";
  55. tab[3000]="trzy tysiace";
  56. tab[4000]="cztery tysiace";
  57. tab[5000]="piec tysiecy";
  58. tab[6000]="szesc tysiecy";
  59. tab[7000]="siedem tysiecy";
  60. tab[8000]="osiem tysiecy";
  61. tab[9000]="dziewiec tysiecy";
  62. tab[10000]="dziesiec tysiecy";
  63. int pLiczba,kon=0,pR=0;
  64. do{
  65. if (pR==1) getch();system("cls");
  66. do{
  67. if (kon==0) cout<<"Podaj liczbe: ";else cout<<"Podaj wartosc z przedzalu <0,10000>): ";
  68. kon=1;cin>>pLiczba;}while((pLiczba<0)||(10000<pLiczba));
  69. kon=0;
  70. ostringstream ss;
  71. ss << pLiczba;
  72. string liczbaS = ss.str();
  73. int dlS=liczbaS.length();
  74. string budS;
  75. string budC="";
  76.    int prob,elA=dlS-1;
  77.    
  78.    for(int i=1;i<=dlS;i++){
  79.     budS="";
  80.     char ch=liczbaS[i-1];
  81.     char ch1=liczbaS[i];
  82.     int li=ch-'0';
  83.     int li1=ch1-'0';
  84.     if((i==dlS-1)&&(li==1)&&(li1!=0)){
  85.        budS=tab[10+li1]; i=dlS;}
  86.        else budS=tab[li*zeraP(elA)];
  87.     budC+=budS+" ";
  88.     elA--;     
  89.    }           
  90. cout<<budC;
  91. pR=1;}while(pLiczba!=0);
  92. return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement