注册 登录
编程论坛 C++教室

高手看一下这是什么运算?

小编程员 发布于 2009-09-18 13:20, 600 次点击
#include<iostream.h>
void main()
{int x=1,y=2,z=3;
x=x^z;
y=y^z;
z=x^y;
cout<<x<<y<<z;}
输出结果是213,请高手看一下,这是什么运算。在VFP中是乘方,但这里不是。
5 回复
#2
kxalpah2009-09-18 13:58
按位异或,x^z = 1^3 = 0001 ^ 0011 = 2;
#3
sealan20052009-09-18 17:35
x = x^z = 1^3 = 0001 ^ 0011 = 0010 = 2;  x = 2;
y = y^z = 2^3 = 0010 ^ 0011 = 0001 = 1;  y = 1;
z = x^y = 2^1 = 0010 ^ 0001 = 0011 = 3;  z = 3;
#4
哎呀麦兜2009-09-18 21:32
那要请问一下,要是表达成方的话怎么样表示?
#5
shl3052009-09-18 23:06
乘方没有直接运算符,要用库函数pow()
#6
qlc002009-09-19 21:07
#include <iostream.h>
#include <math.h>
int main()
{
    int a,b;
    int sum;
    cin>>a>>b;
    sum=pow(a,b);
    cout<<sum<<endl;
    return 0;
}
这里面就可以使用pow()了
1