cpp: data type
#include<iostream> #include<stdio.h> #include<string.h> //显示中文,需要引用 using namespace std; void test() { int i = 10; for (int j = 0; j <= 3; j++) cout << j + i << endl; cout << "geovindu" << endl; } /* 数据类型占用内存空间 */ void dataTypeSize() { short sa = 10; int sb = 90; long sc = 800823232; string sd = "涂聚文(Geovin Du)"; char se; //字符串不能多个 se = 'g'; //char* a[] long sf = 0.84343; long long sl = 83434343; double sdo = 243; float sff = 243.5; cout << "short数据类型变量sa占用内存空间" <<sizeof(sa) << endl; cout << "int数据类型变量sb占用内存空间" << sizeof(sb) << endl; cout << "long数据类型变量sc占用内存空间" << sizeof(sc) << endl; cout << "string数据类型变量sc占用内存空间" << sizeof(sd) << endl; cout << "long数据类型变量sc占用内存空间" << sizeof(sf) << endl; cout << "long long数据类型变量sc占用内存空间" << sizeof(sl) << endl; cout << "double数据类型变量sc占用内存空间" << sizeof(sdo) << endl; cout << "float数据类型变量sc占用内存空间" << sizeof(sff) << endl; cout << "char数据类型占用内存空间" << sizeof(char) << endl; cout << "bool数据类型占用内存空间" << sizeof(bool) << endl; } /* */ void intput() { string a; cout << "请输入你的名字:" << endl; cin >> a; cout << "你输入的名字是:" << a << endl; } /* 显示五星列行排列 */ void displayFiveStars() { for (int i = 1; i < 5; i++) { for (int j = 1; j < 6; j++) { cout << "\t*"; } cout << endl; } } /* 输入参数显示五星列行排列 */ void displayFiveStars(int row, int column) { for (int i = 1; i < row; i++) { for (int j = 1; j < column; j++) { cout << "\t*"; } cout << endl; } } /* ASCLL */ void displayASCII(char ascii[]) { //char ascii[] = "abcd"; int lengf = sizeof(ascii); for(int i=0;i<lengf;i++) { cout << int(ascii[i]) << endl; } } /* 运算符 */ void dipslayOperate(long a, long b) { if (b > 0) { cout << "a+b=" << a + b << endl; cout << "a-b=" << a - b << endl; cout << "a*b=" << a * b << endl; cout << "a/b=" <<a /b << endl; cout << "a%b=" << a % b << endl; } else { cout << "不能为零" << endl; } } /** * * 三目运算符 */ void TrinocularOperator(int a,int b) { int c = a < b ? a : b; cout << "c=" << c << endl; } /* 考试成绩判断 */ void IsPassExamination(long exam) { if (exam > 100) { cout << "输入的分数有误!" << endl; } else if (exam >= 80) { cout <<"你的【"<<exam<< "】分考试成绩优秀" << endl; } else if (exam >= 60) { cout << "你的【" << exam << "】分考试成绩极格" << endl; } else { cout << "你的【" << exam << "】分考试成绩不及格" << endl; } } #define day 7 //宏常量,定义以后,左不能修改 不加分号 int main() { for (int i = 0; i < 10; i++) { long exam = 0; char yes = 'Y'; cout << "输入你的考试成绩分数:" << endl; cin >> exam; IsPassExamination(exam); cout << "是否继续输入(y/n)?" << endl; cin >> yes; if (yes == 'N' || yes == 'n') { break; } } //显示星号 //displayFiveStars(); //displayFiveStars(8,8); //char asciid[]={ 'A','b','c','D' }; //displayASCII(asciid); // //dipslayOperate(12, 3); short sa = 10; int sb = 90; long sc = 800823232; string sd = "涂聚文(Geovin Du)"; char se; //字符串不能多个 se='g'; //char* a[] long sf = 0.84343; long long sl = 83434343; double sdo = 243; float sff = 243.5; char dustr[] = "geovindu"; char chinses[] = "中国人"; cout << chinses[2] << endl; dataTypeSize(); cout <<"char"<< int(se) << endl; bool isok = true; cout << "逻辑:" << isok << endl; test(); string du = "涂聚文(Geovin Du)"; cout << "helo world!" << endl; cout <<"一周共有:"<<day<<"天"<<endl; cout << du << endl; const int month = 12; //常量 cout <<"一年有多少个月:"<< month << endl; system("pause"); return 0; }
vs2022 python 输出中文乱码,python程序文件的文件编码的原因产生的。而PyCharm 2022.3.2 没有此问题。
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)