#include <iostream>
using namespace std;
typedef unsigned short UINT16; // 给unsigned short起别名
#define _CRT_SECURE_NO_WARNINGS 0 //关闭警告
int main(void){
float fScore = -0.23;
fScore = fScore >= 0 ? fScore : 0; //fScore>=0,则赋给fScore;否则赋0
cout << fScore << endl;
//类型转换 隐式
int i = 97;
float f = i; //将整数作为浮点数表示; 隐式类型转换
cout << "f= " << f << endl;
double d = 3.1415926;
float f1 = (float)d; // 加(float) 消除警告 显式类型转换
cout << "f1=" <<f1 << endl;
}
1.6 基本数据类型及表达式 【C++】
最新推荐文章于 2023-12-09 14:08:19 发布