cpp: data type

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#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 没有此问题。

 

 

 

posted @   ®Geovin Du Dream Park™  阅读(23)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
历史上的今天:
2015-04-02 sql: postgreSQL9.3 sql script
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示