ASCII тэмдэгтүүдээс аравтын тоог гарга.
#include <ctype.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
char *binary(int a)
{ char *b,t=7;
b=(char*)malloc(9);
strcpy(b,"00000000");
while (a) { b[t]=(char)(a % 2 + '0');
a/=2; t--;
}
b[8]=NULL;
return &b[0];
}
main()
{ int i;
printf (" Aravtyn tsifruud:\n\n", i);
printf(" Dec Hex Binary Char \n");
for (i=0;i<256;i++)
if (isdigit(i) != 0)
printf("%5d%5X%12s%5c\n",i,i,binary(i),i);
getch();
}
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
char *binary(int a)
{ char *b,t=7;
b=(char*)malloc(9);
strcpy(b,"00000000");
while (a) { b[t]=(char)(a % 2 + '0');
a/=2; t--;
}
b[8]=NULL;
return &b[0];
}
main()
{ int i;
printf (" Aravtyn tsifruud:\n\n", i);
printf(" Dec Hex Binary Char \n");
for (i=0;i<256;i++)
if (isdigit(i) != 0)
printf("%5d%5X%12s%5c\n",i,i,binary(i),i);
getch();
}
Comments
Post a Comment