C++的一些基础

首先,欢迎每个热爱编程的人!

这里是我对于C++的理解

那么我们现在就步入主题━( *`∀´ *)ノ!

框架

头文件

头文件是每个C++程序必不可少的一个内容
它们的格式是 # + include + < + 头文件内容 + >
例如:

#include<iostream>//包含头文件    输入输出流
                  //            (input)(output)(stream)
                  //               ↓      ↓       ↓
                  //               i      o     stream
#include<bits/stdc++.h>//万能头文件
#include<cmath>//数学符号的使用  如 abs()是绝对值  sqrt()是平方根

命名空间 及 主函数 及 停止

using namespace std;//准许使用命名空间
int main(){         //主函数开始
    
    return 0;       //停止运行
}

输出

输出,作为程序对你的反馈
可以用cout输出
而cout有多种输出方法

#include<iostream>
using namespace std;
int main(){
    int a=0;
    cout<<"输出内容";//直接输出""里的内容
    cout<<1145;//输出数字
    cout<<1+1;//输出表达式结果
    cout<<a;//输出变量的值
    cout<<endl;//换行
    return 0;
}

可以讲一下define

2 个赞

https://discourse.xinyoudui.com/t/topic/21578

突然想起来原来的东西,我准备复更

1 个赞

我去,7月老物

1 个赞

这里主要是讲一下一些较为基础的东西

至于define…

我也不太会用

这么巧??!

我都不知道我的多久没更新了

1 个赞

主要是写的太多了,也没人看

1 个赞

把基础框架写出来吧,这样新手每次就不用手打基础框架了(虽然我一般就手打)

1 个赞

#define XX YY

指的是将 XX 变为 YY

1 个赞

啊我用大typedef

1 个赞
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
1 个赞

就这3句就够了,那些装逼的就不用le吧

1 个赞

后面的在这里↓

https://discourse.xinyoudui.com/t/topic/38901
https://discourse.xinyoudui.com/t/topic/38877

#include <bits/stdc++.h>
using namespace std ;
const int N = 1e5 + 5 ; // n的大小以题目中的为准
struct Node {
    int score ;
    int /*string*/ id;// 当id是字符时用string
    int x ;// 坐标x、y
    int y ;
} node [ N ] ;
bool cmp ( Node a , Node b ) {
    if ( a.score == b.score ) {
        return a.id < b.id ;
    }
    else {
        return a.score < b.score ;
    }
    if ( a.x == b.x ) {
        return a.x < b.x ;
    }
    else {
        return a.y < b.y ;
    }
}
int main (void) {
    
    return 0;
}