11368人加入学习
(31人评价)
【旧版】C++编程系列 预备季快速上手

旧版课程,制作完成于2017-12-18

价格 免费

循环语句

1.while

while(表达t/f){

循环体

}

2.do while

3.for

while loop

int main()

{

int count=0;

while(count<10){

cout<<"生成一个敌人"<<endl;

count++;

}

cout<<"while循环下面的代码"<<endl;

return 0;

}

[展开全文]

Ctrl+k Ctrl+c 注释多行 Ctrl+K Ctrl+u 取消注释

 

但是特么的没说endl的作用 健忘的SIKI

~

常量 就是写的那个数字

[展开全文]

true代表真,有,存在的意思,一般也使用1代表

false代表假,没有,不存在的意思,一般也使用0代表

==等于,完全相同

!=不等于

什么是逻辑运算符

&&判断两个条件是否同时满足true,否则其他任何情况都是返回false

||判断两个条件是否都等于false,否则其他全部都是true

!

[展开全文]

do while loop(先执行一次循环体)

int main()

{

int count=0;

do{

cout<<"生成一个敌人"<<endl;

count++;

}while(count<10);

cout<<"while循环下面的代码"<<endl;

return 0;

}

for loop

for(表达式1;表达式2;表达式3){

循环体

}

int main()

{

for(int i=0;i<10;i++){

cout<<"生成一个敌人"<<endl;

}

cout<<"循环下面的代码"<<endl;

return 0;

}

循环中断

break、continue

终止循环

int main()

{

int count=0;

while(count<10){

cout<<"生成一个敌人"<<endl;

count++;

if(count==5){

break;

}

}

cout<<"循环下面的代码"<<endl;

return 0;

}

 

 

 

 

 

 

 

 

 

 

 

[展开全文]

\n

endl

两者等价

 

[展开全文]
张鹏宇 · 2018-01-14 · 09-变量 0

struct + 结构体名字{

            成员类型 名字

            成员类型 名字

}

[展开全文]

Function

//定义函数

void createEnemy(){

cout<<"生成敌人的第一个步骤"<<endl;

}

 

//调用函数

int main()

{

createEnemy();

return 0;

}

 

[展开全文]

函数参数的作用

参数可添加可不添加,参数可以是任意类型的

#include<iostream>

#include<string>

using namespace std;

void createEnemy(int enemyType,int pos,string name){

if(enemyType==1){

 

cout<<"生成敌人的第一个步骤"<<endl;

}

cout<<"生成敌人的第二个步骤  设置位置到"<<pos<<endl;

cout<<"生成敌人的第三个步骤 发生变化"<<endl;

}

 

//调用函数

int main()

{

createEnemy(1,100,"神奇女侠");

 

createEnemy(2,50,"神奇男侠");

return 0;

}

 

 

返回值的作用

void createEnemy(int enemyType,string name){

if(enemyType==1){

 

cout<<"生成敌人的第一个步骤"<<endl;

}

cout<<"生成敌人的第二个步骤  设置位置到"<<endl;

cout<<"生成敌人的第三个步骤 发生变化"<<endl;

if(enemyType==1){

return 90;

}

else{

return 100;

}

}

 

//调用函数

int main()

{

int pos=createEnemy(1,"神奇女侠");

cout<<"生成的位置是"<<pos<<endl;

createEnemy(2,"神奇男侠");

return 0;

}

//example

int add(int arg1,int arg2){

int res=arg1+arg2;

return res;

}

int main()

{

int a=100;

int b=90;

int res=add(a,b);

cout<<res<<endl;

return 0;

}

[展开全文]

枚举类型:

enum

 

 

#include #include using namespace std; enum WeekDay{ Monday,Tuesday,Wednesday,Thurday,Friday,Saturday,Sunday; } int main() { int weekday=1; WeekDay = Friday; cout << day <

[展开全文]

字符串的使用

#include<iostream>

#include<string>

using namespace std;

 

int main()

{

string s="sikedu.com";

//char c=s[0];

//cout<<s[0]<<endl;

//cout<<s[1]<<endl;

//for(char c;s){

//cout<<c<<endl;

//}

char c='C';

//cout<<islower(c)<<endl;

putchar(tolower(c));//转化成小写字母

return 0;

}

输入

int main()

{

/*int num;

cin>>num;

cout<<num;*/

/*string name;

string name2;

cin>>name;

cin>>name2;

cout<<"你输入的是:"<<name<<":"<<name2<<endl;*/

string l;

getline(cin,l);

cout<<"你输入的是:"<<l<<end;

return 0;

}

 

 

[展开全文]


#include "pch.h"
//包含一个库
#include <iostream> 
#include "ConsoleTest1.h"
using namespace std;

//main  函数
int main()
{
    NewFunction();

    CreatEnemy(1, 2, "sfa");
    //CreatEnemy(2, 1, "xss");
    return 0;
}


void CreatEnemy(int EnemyType, int pos, string name) {

    if (EnemyType == 1)
    {
        cout << EnemyType << "的fewfS敌人" << endl;

    }
    else
    {
        cout << EnemyType << "dedassadad 敌人" << endl;
    }
    cout << pos << endl;
    //cout << name << endl;

}


void NewFunction()
{
    //console out           end line       
    cout << "Hello World!" << endl;
    /*
    int age;
    cin >> age;
    cout << "safasdf" << age << endl;*/

    int num1 = 30;
    int num2 = 20;

    int sum = num1 % num2;
    cout << sum;


    switch (1)
    {
    case 1:
    case 2:
    case 3:
        cout << "_____________________________" << endl;
        break;
    }

    int count = 0;
    while (count < 100)
    {
        cout << count << endl;
        count++;
    }
    cout << "--------------" << endl;
    for (int i = 0; i < 10; i++)
    {
        cout << i << endl;
    }
}


void Creat() {
    cout << 123;
}


 

[展开全文]

结构体

把不同类型组合形成新的类型

struct 名字{

成员类型 成员名;

成员类型 成员名;

}

 

#include<iostream>

#include<string>

using namespace std;

 

struct Position{

float x;

float y;

float z;

}; 

struct Enemy

{

string name;

int hp;

int attack;

Position pos;

};

int main(){

/*float  enemy1X;

float  enemy1Y;

float  enemy1Z;*/

Position enemy1Pos={100,20,90};

 

//enemy1Pos.x=90;

//enemy1Pos.y=10;

//enemy1Pos.z=12;

//cout<<enemy1Pos.y<<endl;

 

/*float  enemy2X;

float  enemy2Y;

float  enemy2Z;*/

//Position enemy2Pos;

Enemy enemy1={"siki",100,50,{1,1,1}};

Enemy enemy2;

cout<<enemy1.pos.s<<endl;

return 0;

}

 

 

[展开全文]
  • cin cout 后面接着<<"想要输入的字符串"<<
  • 字符串输出都需要加上<< " "<<包围

 

[展开全文]

 “\n”"Tab" 在C++中必须用“包围上

 

[展开全文]

1.解决方案下多个项目。

2.启动项目-调试启动的项目

3.资源文件

头文件

源文件

[展开全文]

void* p1;//空类型指针,可以指向任意类型的地址

[展开全文]

授课教师

SiKi学院老师

课程特色

图文(1)
下载资料(2)
视频(40)