本人新手一名,想先用原始的方法做
#include<stdio.h>
#include<stdlib.h>
int main()
{
char num;
int a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1,a8,b8,c8,d8,e8,f8,g8,h8;
printf("Pls enter a capital letter:");
scanf("%c",&num);
printf("%d\n",num);
a=num;
b=a/2;
c=b/2;
d=c/2;
e=d/2;
f=e/2;
g=f/2;
h=g/2;
a1=a%2;
b1=b%2;
c1=c%2;
d1=d%2;
e1=e%2;
f1=f%2;
g1=g%2;
h1=h%2;
printf("%d%d%d%d%d%d%d%d",h1,g1,f1,e1,d1,c1,b1,a1);
a8=0;
b8=1;
c8=2;
d8=3;
e8=4;
f8=5;
g8=6;
h8=7;
if(c1=0&&b1=0&&a1=0)
{c1,b1,a1=a8}
printf("a8");
system("pause");
return 0;
}
10进制转2进制那里顺利了,二进制转八进制那里碰壁了,不知我的方法对不对所以先写了开头。
能帮帮忙看看哪里有错误吗?谢谢
#include<stdio.h>
#include<stdlib.h>
int main()
{
char num;
int a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1,a8,b8,c8,d8,e8,f8,g8,h8;
printf("Pls enter a capital letter:");
scanf("%c",&num);
printf("%d\n",num);
a=num;
b=a/2;
c=b/2;
d=c/2;
e=d/2;
f=e/2;
g=f/2;
h=g/2;
a1=a%2;
b1=b%2;
c1=c%2;
d1=d%2;
e1=e%2;
f1=f%2;
g1=g%2;
h1=h%2;
printf("%d%d%d%d%d%d%d%d",h1,g1,f1,e1,d1,c1,b1,a1);
a8=0;
b8=1;
c8=2;
d8=3;
e8=4;
f8=5;
g8=6;
h8=7;
if(c1=0&&b1=0&&a1=0)
{c1,b1,a1=a8}
printf("a8");
system("pause");
return 0;
}
10进制转2进制那里顺利了,二进制转八进制那里碰壁了,不知我的方法对不对所以先写了开头。
能帮帮忙看看哪里有错误吗?谢谢