当前位置:网站首页>Exclusive or operator simple logic operation a^=b
Exclusive or operator simple logic operation a^=b
2022-06-25 23:02:00 【if you never leave me, i will be with you till death do us apart】
^ Is a bitwise XOR operation
a^=b Equivalent to a = ab, among It's a bitwise exclusive or operation , the a And b XOR operation on the corresponding bit of , A fellow 0 Or both 1 when , The corresponding bit result is 0; Otherwise 1.
hypothesis ,a The value of is binary 1010,b The value of is binary 1100, that a^b = 0110
describe
Enter two positive integers a and b, Output the sum of these two positive integers , Bad , product , merchant , model ( if a>b The output a-b,a/b,a%b The value of... Is output in reverse b-a,b/a,b%a Value , Do not consider decimals , Please use int type )
Input description :
Two positive integers
Output description :
Their and , Bad , product , merchant , model . Each value is separated by a space
Example 1
public static void main(String[] args) {
System.out.println(" Please enter two decimal places ");
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
scanner.close();
// The above code Basic is the basic data input
// Here's your judgment Default to a>b When By default, the data of the following program will be used ( skip if) In line with business logic
// When he was less than b Enter the following if
//EG:a=10 2 Of 3 Power +2 Of 1 The second party is =10 So his value is 1010
// b=20 2 The fourth power of +2 To the power of = 10100
if (a < b) {
//a=a^b a= 1010^10100= 1110 =30
a ^= b;
//b= b^a; a=30 b=20 20^30=10 b=10
b ^= a;
//a=a^b a=30 b=10 a=20 b=10 Equivalent position It is equivalent to changing the value position
a ^= b;
}
// %d: Integer output Convert the contents of his output to the shape output
System.out.printf("%d %d %d %d %d", a + b, a - b, a * b, a / b, a % b);
}
The result of his output is :
Please enter two decimal places
10
20
30 10 200 2 0
Another relatively simple method of operation :
if(a>b){
System.out.println((a+b)+" "+(a-b)+" "+(a*b)+" "+(a/b)+" "+(a%b));
}else{
System.out.println((a+b)+" "+(b-a)+" "+(a*b)+" "+(b/a)+" "+(b%a));
}
}
边栏推荐
- 2022-2028 global variable frequency compressor technology industry research and trend analysis report
- Flutter 网络请求封装之Dio(Cookie管理、添加拦截器、下载文件、异常处理、取消请求等)
- Hotspot JVM "01" class loading, linking and initialization
- 2022-2028 global cloud based remote browser isolation industry research and trend analysis report
- Unity技术手册 - 生命周期旋转RotationOverLifetime-速度旋转RotationBySpeed-及外力
- Obsidian basic tutorial
- adb常用命令
- Fastjson deserialization randomness failed
- What do l and R of earphone mean?
- NRM source switching tool
猜你喜欢

Trillions of hot money smashed into the space economy. Is it really a good business?

2022-2028 global co extrusion production line industry research and trend analysis report
![[WPF] XAML code skills that can be directly used for converting CAD engineering drawings to WPF](/img/a1/09d2dc0ec47c54530da4d42d218d1c.jpg)
[WPF] XAML code skills that can be directly used for converting CAD engineering drawings to WPF

2022年河南省第一届职业技能大赛网络安全项目试题

NRM source switching tool

Utilisation de la classe Ping d'Unity
![[eosio] eos/wax signature error is_ Canonical (c): signature is not canonical](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[eosio] eos/wax signature error is_ Canonical (c): signature is not canonical

ES6-- 模板字符串、对象的简化写法、箭头函数
This 110 year old "longevity" enterprise has been planning for the next century

2022-2028 global extrusion coating and lamination production line industry research and trend analysis report
随机推荐
作为一个程序员我们如何快乐的学习成长进步呢?(个人感悟和技术无关)
2022-2028 global proton exchange membrane hydrogen electrolyzer industry survey and trend analysis report
Online crudhasone Association query reports an error unabletouseinternalvariable:list
Analysis report on demand and investment forecast of global and Chinese flame retardant hydraulic oil market from 2022 to 2028
Touring band: a 5g based multi camera remote distributed video production experiment
The new version of Tencent's "peace elite" is coming: add a new account security protection system, and upgrade the detection of in-game violations
提问的智慧?如何提问?
Yyds dry goods inventory JD 2, why is redis so fast?
adb常用命令
Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology
ES6-- 模板字符串、对象的简化写法、箭头函数
2022-2028 global SiC igniter industry research and trend analysis report
Unity技术手册 - 粒子发射和生命周期内速度子模块
Chapter 3 use of requests Library
2022-2028 global vacuum jacket system industry survey and trend analysis report
[dynamic programming] longest palindrome substring thinking about dynamic transfer cycle sequence
Some reflections on preparing for the Blue Bridge Cup
2022-2028 global horizontal reciprocating compressor industry research and trend analysis report
APP测试要点
Three layer architecture + routing experiment