C语言怎么把字符数字转化成数字数字转化为字符?
char ch = '7 ';
int nch = ch - '0 ';
int n = 7;
char chn = n + '0 ';
#include <iostream>
using namespace std;
int main()
{
int i=300;
int j;
for (j=15;j>=0;j--)
{
if(((1<<j)&1)!=0)
cout<<1<<endl;
else
cout<<0<<endl;
}
return 0;
}
输出结果最后一个是1 其他全部是0
#include <iostream>
using namespace std;
class a{
public:
a(){
cout<<"a+";
}
~a()
{
cout<<"a-";
}
};
class c{
public:
c(){
cout<<"c+";
}
~c(){
cout<<"c-";
}
};
class b:public a{
public:
b()
{
cout<<"b+";
}
~b(){
cout<<"b-";
}
c c1;
};
int main()
{
b b1;
return 0;
}
输出:a+c+b+b-c-a-
#include <iostream>
using namespace std;
int main()
{
char const*s="hello,baofenger";
char a[16];
strcpy(s,a);
return 0;
}
#include <string.h>
char *strcpy( char *to, const char *from );
“strcpy”: 不能将参数 1 从“const char *”转换为“char *”
#include <iostream>
using namespace std;
#include <cstring>
int main()
{
inta[3][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12}};
cout<<*a[0]<<endl;
cout<<a[1][3]<<endl;
cout<<**(a+0)<<endl;
cout<<*(*a+2)+2<<endl;
cout<<*(*(a+2))+2<<endl;
return 0;
}
输出1 8 1 5 11
关于海量用户积分排名的算法
参考地址:http://www.cnblogs.com/weidagang2046/archive/2012/03/01/massive-user-ranking.html