(1) 求输出结果(本题的作用是什么)
#include <stdio.h>
void main()
{
int y = 18, i = 0, j, a[8];
do
{
a[i] = y%2;
i++;
y = y/2;
}while(y >= 1);
for(j = i-1; j >= 0 ;j--)
printf ("%d",a[j]);
}
(2)输入 -3456,求输出结果(本题的作用是什么)
#include <stdio.h>
#include <string.h>
main()
{
char s[6];
int n;
gets(s);
if(*s=='-')
n=-chnum(s+1);
else
n=chnum(s);
printf("%d\n", n);
}
chnum(char *p)
{
int num=0, k, len, j;
len = strlen(p);
for(; *p!='\0'; p++)
{
k = *p-'0';
j = (--len);
while (j-- > 0)
k = k*10;
num = num + k;
}
return (num);
}