自学内容网 自学内容网

2024新版 黑马程序员《C++零基础入门》笔记——第一章03 符号常量

1.符号常量

2.代码文件

方式1:引入windows.h库

# include "iostream"
# include "windows.h"

using namespace std;
# define FAT_BMI 28
# define J2C_RATE 4.19

int main()
{
    SetConsoleOutputCP(CP_UTF8);
    cout << FAT_BMI << endl;
    cout << "焦耳转卡路里需要除以:" << J2C_RATE << endl;
    return 0;
}

方式2:system(“chcp 65001”);

# include "iostream"

using namespace std;
# define FAT_BMI 28
# define J2C_RATE 4.19

int main()
{
    system("chcp 65001");
    cout << FAT_BMI << endl;
    cout << "焦耳转卡路里需要除以:" << J2C_RATE << endl;
    return 0;
}

3.总结

4.练习作业

// Created by 黑马程序员.
#include "iostream"
#include "windows.h"
using namespace std;

#define NAME "周杰轮"
#define AGE 21
#define HEIGHT 180.5
#define WEIGHT 56

int main()
{
    SetConsoleOutputCP(CP_UTF8);    // 修改字符编码,解决中文乱码
    cout << "我是" << NAME << ",今年" << AGE << "岁。" << endl;
    cout << "身高" << HEIGHT << "cm,体重" << WEIGHT << "KG。" << endl;
    return 0;
}


原文地址:https://blog.csdn.net/m0_55841508/article/details/140700161

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!