2021-07-06

7.5课堂笔记
1.字符长度
Char-----1字符
Short-----2字符
Int-----4字符
Long int-----4字符
Long long-----8字符
Float-----4字符
Double-----8字符
Long double-----12字符
Bool-----1字符
Void

#include<iostream>
using namespace std;
int main()
{
	cout << "char size" << sizeof(char) << endl;
	cout << "short size" << sizeof(short) << endl;
	cout << "int size" << sizeof(int) << endl;
	cout << "long int size" << sizeof(long int) << endl;
	cout << "long long size" << sizeof(long long) << endl;
	cout << "float size" << sizeof(float) << endl;
	cout << "double size" << sizeof(double) << endl;
	cout << "long double size" << sizeof(long double) << endl;
	cout << "bool size" << sizeof(bool) << endl;
}

2.✳的意义
乘号:
int c = a*b;
int a=2,b=3;

声名:
int *i,*j;

解引用:
int a=100;
int *p=&a;
x=*p;
x =100;

3.ASCII码
特殊:
1----------49
A----------65
a----------97
空格------32

4.指针复习

#include<iostream>
using namespace std;
int main()
{
	int a = 10, b = 20;
	int* p = NULL;
	p = &a;
	*p = 100;
	p = &b;
	*p = 200;
	return 0;
}

p在此处指的为a和b的地址
*p指的为a和b本身的值

5.判断闰年

#include<iostream>
using namespace std:
void Is_leap()
{
	int year;
	scanf_s(“%d”,&year);
	if((year%4==0&&year%100!=0)||year%400==0)
	{
		res= true;
	}
	return res;
	else
	{
	return false;
	}
}

6.已知某一年的某一月,求这一月的天数

#include<iostream> 
using namespace std;
 int Get_YM_Day(int year,int month)
{
	int day=0;
	switch(month)
	{
		case 1: case 3: case 5: case 7: case 8: case 10: case 12:
			day=31;
			break;
		case 4: case 6: case 9: case 11:
			day=30;
			break;
		default:
			if(Is_Leap(year)){ day=29;	}
			else{  day=28;	}
	} return 0;
}

7.已知某日具体日期,求这是这一年的哪一天

#include<iostream>
using namespace std;
int Get_YM_Day(int year,int month)
{  
	static const int day[13]={29,31,28,31,30,31,30,31,31,30,31,30,31}
	//           0  1  2  3  4  5  6  7  8  9  10 11 12 
		if (month==2 && Is_Leap(year) )
{
	month=0;
} return day[month];
}
int Get_YMD_Total(int year,int month,int day)
{
	int day[13]={29,31,28,31,30,31,30,31,31,30,31,30,31}
	int sum=0;
	if (year<1) return -1;
	if (month<1||month>12) return -2;
	if (day<1||day>Get_YM_Day(year,month)) return -3;
	for(i=1,i<month,++i)
	{ 
	sum=sum+Get_YM_Day(year,i);
	}
    return sum+day;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值