C++入门经典-例2.17强制类型转换

1:代码如下:

// 2.17.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include<iostream>
using namespace std;
void main()
{
    float i, j;
    int k;
    i = 60.25;
    j = 20.5;
    k = (int)i + (int)j;
    cout << k << endl;
}
View Code

运行结果:

posted @ 2017-09-11 19:09  一串字符串  阅读(198)  评论(0编辑  收藏  举报