Advertisement
Adrita

sem 2 lab 6

Sep 9th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include<stdio.h>
  2. int main() {
  3. long a,l=0,len,i,p;
  4. char ar[1000],z;
  5. scanf("%ld",&a);
  6. for(i=0; a>0; i++) {
  7. if(a>26) {
  8.  
  9. if(a%26==0) {
  10. z='Z';
  11. a=(a/26)-1;
  12. } else {
  13. z='A'+(a%26)-1;
  14. a=a/26;
  15. }
  16. ar[i]=z;
  17. } else if(a<=26) {
  18. z='A'+a-1;
  19. ar[i]=z;
  20. break;
  21. }
  22. }
  23. len=strlen(ar);
  24. for(i=0; i<len; i++) {
  25. printf("%c",ar[len-1-i]);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement