一、知识点
1、表达式中数据类型的转换
(类型名)(表达式)
例如
(double)a 将a转换为double
(int)(x=y) 将x=y转换为int
(float)(5%3) 将5%3转换为float
注:括号不能省略
今天的代码来喽
#include "stdafx.h"
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int x;
cout << "请输入需要判断的年份" << endl;
cin >> x;
if (x % 4 != 0 || x % 400 == 0)
cout << "该年份不是闰年" << endl;
else
cout << "该年是闰年" << endl;
cin.get();
cin.get();
return 0;
}
今天也要努力吖
I hope you can keep half of your loveliness
and gentleness under all kinds of
difficulties in life.
在生活的万般刁难下
愿你留住半分可爱和温柔