十六进制转八进制
#include<stdio.h>
#include<string.h>
int main()
{
int n,i,b,k,a,c,d,m,l;
char s[10][100001],d16[16][5]={"0000","0001","0010","0011","0100","0101","0110","0111","1000","1001","1010","1011","1100","1101","1110","1111"},out[140000]={},z[13]={};
scanf("%d",&n);
for(b=0;b<n;b++)
scanf("%s",s[b]);
for(b=0;b<n;b++)
{
k=0;d=1;m=0;
l=strlen(s[b]);
a=3-l%3;
if(a==3) d=0;
for(i=0;i<l;i++)
{
if(65<=s[b][i])
s[b][i]-=7;
if(d)
if(a==1){
strcat(z,"0000");k=k+4;ok=0;
}else if(a==2){
strcat(z,"00000000");k=k+8;ok=0;
}
z[k++]=d16[s[b][i]-48][0];
z[k++]=d16[s[b][i]-48][1];
z[k++]=d16[s[b][i]-48][2];
z[k++]=d16[s[b][i]-48][3];
if(k==12)
{
for(c=0;c<12;m++)
out[m]=((z[c++]-48)*4+(z[c++]-48)*2+(z[c++]-48)*1)+48;
z[0]='\0';k=0;
}
}
for(;k<3;k++)
if(out[k]!=48) break;
for(;k<m;k++)
printf("%c",out[k]);
putchar('\n');
}
return 0;
}
视频学习:关系运算符和关系表达式
关系运算符eg:bool
#include<iostream>
using namespace std;
int main()
{
int n1 = 4,n2 = 5,n3;
n3 = ( n1 > n2);
cout << n3 << ",";
n3 = ( n1 < n2);
cout << n3 << ",";
n3 = (n1 != 4);
cout << n3 << ",";
n3 = (n1 == 5);
cout n3;
return 0;
}
逻辑运算符和逻辑表达式:逻辑运算符用于表达式的逻辑操作,有&&,||,!三种,操作的结果是true,false
#include<iostream>
using namespace std;
int main()
{
int a =0,b =1;
bool n = (a++) && (b++);
cout << a <<"," << b << endl;
n = a ++ && b ++;
cout << a << "," << b << endl;
n = a ++ || b ++;
cout << a << "," << b << endl;
return 0;
}