Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- long n,n0;
- int i,j,imax,A[5],B[5],idem;
- char DOC[10][10]={"khong","mot","hai","ba","bon","nam","sau","bay","tam","chin"};
- printf("nhap n ");
- scanf("%ld", &n);
- if (n==5) printf("\n So tren doc la: nam \n"); //doc so 5 rieng
- else
- { //tach thanh bo 3 chu so
- i=0; idem=0;
- while(n>0)
- {
- i+=1;
- A[i]=n%1000;
- n/=1000;
- }
- printf("\n So tren doc la: \n");
- if (i == 4)
- {
- printf(" %s ty",DOC[A[i]]);
- idem+=1;
- i--;
- } //doc tung bo 3 chu so
- for (;i>0;i--)
- if (A[i]>0)
- {
- for (j=4;j>0;j--) B[j]=0;
- while (A[i]>0)
- {
- j+=1;
- B[j]=A[i]%10;
- A[i]/=10;
- }
- if (idem>0 && j<3) j=3;
- for (;j>0;j--)
- {
- if (j==3) printf(" %s tram ",DOC[B[3]]);
- if (j==2)
- {
- if (B[2]==0 && B[3]*B[1]!=0) printf("linh");
- else if (B[2]==1) printf("muoi");
- else if (B[2]>1)printf(" %s muoi",DOC[B[2]]);
- }
- if (j==1)
- if (B[1]>0)
- if (i==1&&B[1]==5) printf(" lam");
- else printf(" %s ",DOC[B[1]]);
- }
- if (i==3) printf(" trieu");
- else if(i==2) printf(" nghin");
- idem+=1;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement