随笔分类 -  c++代码

摘要://二转十#include<iostream> using namespace std; int main() { string n; cin>>n; int sum=0,p=1; for(int i=n.size()-1;i>=0;i--){ if(n[i]=='1'){ sum+=p; } p* 阅读全文
posted @ 2025-07-29 14:30 王ys 阅读(44) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> using namespace std; int main(){ vector<int> n={3,1,4,1,5,9,2,6}; sort(n.begin(),n.end()); cout<<"升序: "; for(int i:n){ cout<<i 阅读全文
posted @ 2025-07-26 14:58 王ys 阅读(28) 评论(0) 推荐(0)
摘要:// 编译环境:Visual C++ 6.0~2022,EasyX_2023大暑版 // https://easyx.cn // #include <graphics.h> #include <time.h> #include <conio.h> #define MAXSTAR 200 // 星星总 阅读全文
posted @ 2025-07-19 15:46 王ys 阅读(34) 评论(0) 推荐(0)
摘要://"6 9 + 5 3 * - 8 -" #include <bits/stdc++.h> using namespace std; int n,i = 0,a[100]; char a1; int main(){ cin>>n; while(n--){ cin>>a1; if(a1>='1' & 阅读全文
posted @ 2025-07-17 15:48 王ys 阅读(19) 评论(0) 推荐(0)
摘要:#include <graphics.h> // 引用图形库头文件 #include <conio.h> void set_black(int x,int y){ setfillcolor(BLACK); fillcircle(x,y,12); } void set_white(int x,int 阅读全文
posted @ 2025-07-05 16:00 王ys 阅读(27) 评论(0) 推荐(0)
摘要:递归代码 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] 阅读全文
posted @ 2024-11-16 09:59 王ys 阅读(52) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2024-11-01 19:02 王ys 阅读(38) 评论(0) 推荐(0)
摘要:1828:【02NOIP提高组】均分纸牌 时间限制: 1000 ms 内存限制: 65536 KB提交数:2726 通过数: 2102 【题目描述】 有N堆纸牌,编号分别是1,2,3,...N。每堆上有若干张,但纸牌总数必为N的倍数。可以在任一堆上取若干张纸牌,然后移动。移牌规则为:在编号为1的堆上 阅读全文
posted @ 2024-10-19 15:27 王ys 阅读(97) 评论(0) 推荐(0)
摘要://服务端(以C++作范例) #include"mysocket.h" //导入头文件:由于mysock头文件本身就有其它文件,这里无需导入 using namespace std; SOCKET s_accept; int main() { cout << " 服务端 \n"; cout << " 阅读全文
posted @ 2024-09-07 09:14 王ys 阅读(35) 评论(0) 推荐(0)
摘要:#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 阅读全文
posted @ 2024-08-14 09:59 王ys 阅读(42) 评论(0) 推荐(0)
摘要:#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){ 阅读全文
posted @ 2024-07-10 15:59 王ys 阅读(41) 评论(0) 推荐(0)
摘要:1172:求10000以内n的阶乘 时间限制: 1000 ms 内存限制: 65536 KB提交数:51446 通过数: 16810 【题目描述】 求1000010000以内n的阶乘。 【输入】 只有一行输入,整数n(0≤n≤100000)。 【输出】 一行,即n!的值。 【输入样例】 4 【输出样 阅读全文
posted @ 2024-07-10 15:33 王ys 阅读(149) 评论(0) 推荐(0)
摘要:#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 阅读全文
posted @ 2024-06-15 09:57 王ys 阅读(71) 评论(0) 推荐(0)
摘要:#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; 阅读全文
posted @ 2024-06-14 19:57 王ys 阅读(36) 评论(0) 推荐(0)
摘要:服务端 //服务端(以C++作范例) #include"mysocket.h" //导入头文件:由于mysock头文件本身就有其它文件,这里无需导入 using namespace std; SOCKET s_accept; int main() { cout << " 服务端 \n"; cout 阅读全文
posted @ 2024-06-08 10:02 王ys 阅读(49) 评论(0) 推荐(0)
摘要:#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-- 阅读全文
posted @ 2024-06-07 20:28 王ys 阅读(45) 评论(0) 推荐(0)
摘要:#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 阅读全文
posted @ 2024-06-07 19:18 王ys 阅读(39) 评论(0) 推荐(0)
摘要:2032:【例4.18】分解质因数 时间限制: 1000 ms 内存限制: 65536 KB提交数:41561 通过数: 26559 【题目描述】 把一个合数分解成若干个质因数乘积的形式(即求质因数的过程)叫做分解质因数。分解质因数(也称分解素因数)只针对合数。 输入一个正整数&lt;span id 阅读全文
posted @ 2024-06-07 16:16 王ys 阅读(360) 评论(0) 推荐(0)