7628人加入学习
(18人评价)
C++编程系列 第一季编程基础

制作于2018年2月7日

价格 免费

枚举类型关键字 enum herotype{

tank,0

adc,1

assidt 2

 

};

int main(){

 

heroType heroType=tank;

hero

 

 

}

[展开全文]

#include <string>;

#include <iostream>;

#include d"stdafx.h";

using namesoace std;

int main()

{

    stringr str1="nihao";

string str2="hello";

getline(cin,str1);

cout<<str1;

returrn 0;

string s=str1+str2;

s+=str1;

cout<<s<<endl;

cout<<s.size()<<

}

 

[展开全文]

int see[20]={12,545,66,6};

声明和初始化是一起的

 

[展开全文]

#include "stdafx.h"

#include <iostream>

int main(){

float a=3;

int b=3.3;

int c=3e20;

float f-=344.23;

int c=(int)23.5;

int d=int(23.5);

int e=int(f);

 

 

 

 

return 0;

}

[展开全文]

#include "stdafx.h"

#include <iostream>

 

int main(){

 

float a;

cout<<"请输入一个数字"<<endl;

cin>>a;

cout<<a;

cout<<

 

 

 

 

return 0;

 

}

[展开全文]

#include ''stdafx.h'

#include <iostream>

using namespace std;

 

int main()

{

+3.4E9

int t;

cin>>t;

float a=12.2;

double b=23.4;

long double c=231.3;

cout<<a;

 

 

 

 

return 0;

}

[展开全文]

第三题:

// 19-编程练习3.cpp: 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
#include <array>
using namespace std;


int main()
{
    array <float, 4> s = {};
    cout << "请输入你的第一次成绩:";
    cout << endl;
    cin >> s[0];
    cout << "请输入你的第二次成绩:";
    cout << endl;
    cin >> s[1];
    cout << "请输入你的第三次成绩:";
    cout << endl;
    cin >> s[2];
    s[3] = (s[0] + s[1] + s[2]) / 3;
    cout << "你的平均成绩是:" << s[3] << endl;
    return 0;
}

[展开全文]

// 04-字符类型.cpp: 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>

using namespace std;

int main()

    cout << "字母大小写转换程序" << endl;
    cout << endl;
    cout << "请输入字母:";
    char a;
    char c;
    cin >> a;
    cout << endl;

    if (a>=65 && a<=90)
    {
        a = a + 32;
        cout <<"字母转换结果为:"<< a << endl;
    }
    else if (a >= 97 && a <= 122)
    {
        a = a - 32;
        cout << "字母转换结果为:"<< a << endl;
    }
    cout << endl;
    
    return 0;
}

[展开全文]

main()函数是程序的入口

动态链接库不需要main()函数作为入口

[展开全文]

注释快捷键:

加注释:ctrl + k  ctrl + c

去注释:ctrl + k  ctrl + u

[展开全文]
  1. break 跳出循环不再执行
  2. continue 跳出当前循环,执行下一次循环  
[展开全文]
  1. switch只能判断两个值是否相等 
  2.  
[展开全文]
  1.   宏可以代表任何字符串
  2. 宏后面一般不加分号表示结束
  3. typedef只能给类型起别名 
[展开全文]
  1. 对于C语言风格字符串的比较 要用 strcmp()函数比较
  2. 对于string字符串 
[展开全文]
  1. array<int,9>a1={     };  c++11中新的标准 
[展开全文]