随笔分类 - c++代码
摘要:递归代码 int binary_search(int arr[],int left,int right,int key){ if (left>right){//区间无效 return -1; } int mid=left+(right-left)/2; //直接平均可能会溢出 if(arr[mid]
阅读全文
摘要:1828:【02NOIP提高组】均分纸牌 时间限制: 1000 ms 内存限制: 65536 KB提交数:2726 通过数: 2102 【题目描述】 有N堆纸牌,编号分别是1,2,3,...N。每堆上有若干张,但纸牌总数必为N的倍数。可以在任一堆上取若干张纸牌,然后移动。移牌规则为:在编号为1的堆上
阅读全文
摘要://服务端(以C++作范例) #include"mysocket.h" //导入头文件:由于mysock头文件本身就有其它文件,这里无需导入 using namespace std; SOCKET s_accept; int main() { cout << " 服务端 \n"; cout << "
阅读全文
摘要:#include<iostream> using namespace std; int f(int n){ if(n==4){ cout<<"4,5-->9,10\n"<<"8,9-->4,5\n"<<"2,3-->8,9\n"<<"7,8-->2,3\n" <<"1,2-->7,8\n"; }el
阅读全文
摘要:#include<iostream> using namespace std; int jiecheng(int n){ if(n<=2){ return n; } return n*jiecheng(n-1); } int jiechenghe(int n){ int sum; if(n<2){
阅读全文
摘要:1172:求10000以内n的阶乘 时间限制: 1000 ms 内存限制: 65536 KB提交数:51446 通过数: 16810 【题目描述】 求1000010000以内n的阶乘。 【输入】 只有一行输入,整数n(0≤n≤100000)。 【输出】 一行,即n!的值。 【输入样例】 4 【输出样
阅读全文
摘要:#include <iostream> #include "minecraft.h" using namespace std; TxMinecraft mc; int x=-1085,y=64,z=-652; int main(int argc, char** argv) { bool con=mc
阅读全文
摘要:#include<iostream> #include<vector> using namespace std; int main(){ vector<int> a(10,0),c(10,0); a[0]=1; int n; cin>>n; // for(int i=m.size()-1;i>=0;
阅读全文
摘要:服务端 //服务端(以C++作范例) #include"mysocket.h" //导入头文件:由于mysock头文件本身就有其它文件,这里无需导入 using namespace std; SOCKET s_accept; int main() { cout << " 服务端 \n"; cout
阅读全文
摘要:#include<iostream> #include<vector> using namespace std; int main(){ vector<int> a; int b=0; string m; int n; cin>>m>>n; for(int i=m.size()-1;i>=0;i--
阅读全文
摘要:#include<iostream> #include<vector> using namespace std; int main(){ vector<int> a,b; string m,n; cin>>m>>n; for(int i=m.size()-1;i>=0;i--){ a.push_ba
阅读全文
摘要:2032:【例4.18】分解质因数 时间限制: 1000 ms 内存限制: 65536 KB提交数:41561 通过数: 26559 【题目描述】 把一个合数分解成若干个质因数乘积的形式(即求质因数的过程)叫做分解质因数。分解质因数(也称分解素因数)只针对合数。 输入一个正整数<span id
阅读全文
摘要:#include<iostream> #include<vector> using namespace std; int main(){ vector<int> a,b; string m,n; cin>>m>>n; for(int i=m.size()-1;i>=0;i--){ a.push_ba
阅读全文
摘要:#include<iostream> #include<vector> using namespace std; int main(){ vector<int> a; string m; int n; cin>>m>>n; for(int i=m.size()-1;i>=0;i--){ a.push
阅读全文
摘要:#include<iostream> #include<vector> using namespace std; int main(){ vector<int> a,b; string m,n; cin>>m>>n; for(int i=m.size()-1;i>=0;i--){ a.push_ba
阅读全文
摘要:#include<iostream> #include<vector> #include<windows.h> #include<conio.h> using namespace std; int main(){ string m="ddddddddaaaassaaddddaassaaaaddddd
阅读全文
摘要:1839:【05NOIP提高组】谁拿了最多奖学金 时间限制: 1000 ms 内存限制: 65536 KB提交数:30521 通过数: 14617 【题目描述】 某校的惯例是在每学期的期末考试之后发放奖学金。发放的奖学金共有五种,获取的条件各自不同: 1)院士奖学金,每人8000元,期末平均成绩高于
阅读全文
摘要:#include <windows.h> //创建窗口程序的步骤: //1.创建WinMain()主函数 //2.设计窗口 //3.注册窗口 //4.创建窗口 //5.显示窗口 //回调函数,消息处理函数 LRESULT CALLBACK WndProc(HWND hwnd,//窗口句柄 UINT
阅读全文
摘要:#include <iostream>#include <Windows.h>using namespace std;void gr(){ MessageBox(NULL,"游戏结束","是或不是游戏",MB_OK);}int main(int argc, char** argv) { int a=
阅读全文