20241025-C03-运算符+分支
原题链接:33673.徐沐瑶专属笔记C++2024-11-10 17:25:26
发布于:江苏
一、运算符:
(1). 根据功能分类
	1.算术运算符:	+,-,*,/,% 
	2.关系运算符: >, >=, <, <=, ==, !=
	3.逻辑运算符: &&, ||, ! 
	/*		
		逻辑与&&, 逻辑或||, 逻辑非! //(逻辑值, 0, 1)
		and or not
		
		1 && 1 = 1
		1 || 0 = 1
		!0 = 1
		!1 = 0
	*/
	4.自增自减运算符, ++, -- 
		int i = 1;
	//	(++i)使用之前+1,  
	//	(i++)使用之后+1,  
		cout << (++i) << endl;	//2
		cout << i << endl; 		//2
	5.复合运算符: +=, -=, *=, /=, %= 
		
		
		 
(2). 根据操作数的数量分类: 
	单目运算符: ++, -- 
	双目运算符:	a+b, - * /
	三目运算符: (1)?(2):(3) => if...else
二、ASCII 
(American Standard Code for Information Interchange):
美国信息交换标准代码
'a' = 97
'A' = 65
'a' - 'A' = 32 
三、闰年判断 
#if 0
四年一闰, 百年不闰, 四百年再闰 
闰年
普通闰年: y%100!=0 && y%4==0
||
世纪闰年: y%400==0 
#endif 
#include <bits/stdc++.h>
using namespace std;
int main(){
	int y; cin>>y;
	if (y%400==0 || y%100 && y%4==0){
		cout << "闰年"; 
	} 
	else{
		cout <<"平年";
	} 
	return 0;
}
这里空空如也








有帮助,赞一个