1.6 基本数据类型及表达式 【C++】

#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;
 }

在这里插入图片描述

发布了41 篇原创文章 · 获赞 1 · 访问量 480

猜你喜欢

转载自blog.csdn.net/weixin_44773006/article/details/103501799