随笔分类 - Algorithm
摘要:#include<stdio.h> void fun(char *a){ if(*a == '\0'){ return ; } fun(a+1); printf("%c",*a); } int main(){ char s[] = {'a','b','c','d','e'}; fun(s); ret
阅读全文
摘要:#include<stdio.h> void fun(char *str,int len){ for(int i=0;i<len/2;i++){ char temp = str[i];str[i] = str[len-1-i]; str[len-1-i] = temp; } for(int i=0;
阅读全文
摘要:https://blog.csdn.net/qq_36653505/article/details/81701181 https://www.cnblogs.com/kubixuesheng/p/4397798.html
阅读全文
摘要:1 #include<cstdio> 2 #include<cstring> 3 const int N = 10; 4 int a[N][N]; 5 int main(){ 6 int n,x,y,tot; 7 memset(a,0,sizeof(a)); 8 scanf("%d",&n);//n
阅读全文
摘要:1 #include<iostream> 2 using std::cout; 3 4 5 int func(char *s){ 6 if(s==NULL) return -1; 7 8 int num=0; 9 while(*s!='\0'){ 10 num = num*10 + *s - '0'
阅读全文
摘要:1 #include <iostream> 2 using namespace std; 3 4 typedef int elem; 5 6 struct Node{ 7 elem n; 8 struct Node * next; 9 }; 10 11 //创建 12 Node* Create_li
阅读全文
摘要:题意: 比如,输入:I come from China. 输出:China. from come I 思路:先将这个字符串整体倒置,再将单个单词倒置,这样既不需要移动元素,也不需要额外的辅助空间,还可以重用代码,很不错吧。 代码: 1 #include <iostream> 2 3 int len(
阅读全文
摘要:1 #include <iostream> 2 #include <bitset> 3 using namespace std; 4 int main() 5 { 6 int n,m; 7 int len; 8 string temp; 9 bitset<8> t; 10 while(cin>>n>
阅读全文
摘要:1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int MAX = 100; 5 char arr[MAX][MAX];//存放 “w 和 . ” 6 7 int nx[4] = {0,1,0,-1};//4个坐标(0,1)(1
阅读全文
摘要:1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int MAX = 100; 5 char arr[MAX][MAX]; 6 int n,m; 7 8 void init(); 9 void solve(); 10 void d
阅读全文
摘要:1 #include <iostream> 2 using namespace std; 3 4 bool isprime(int a){ 5 6 if(a<=1) return false; 7 8 for(int i=2;i*i<=a;i++){ 9 if(a%i==0) return fals
阅读全文
摘要:1 #include <iostream> 2 using namespace std; 3 4 //最大公约数 5 int gcd(int a,int b){ 6 return b?gcd(b,a%b):a; 7 } 8 9 //最小公倍数 10 int lcm(int a,int b){ 11
阅读全文
摘要:1 #include <iostream> 2 using namespace std; 3 4 void swap(int* a,int* b){ 5 int temp = 0; 6 temp = *a;*a=*b;*b=temp; 7 } 8 9 void qsort(int arr[],int
阅读全文
摘要:1 #include <iostream> 2 using namespace std; 3 const int maxn = 100; 4 5 int merge(int A[],int L1,int R1,int L2,int R2){//L1、R1为第一段区间的左下标与右下标,同理L2、R2
阅读全文
摘要:1 #include <iostream> 2 #include <vector> 3 4 using namespace std; 5 6 vector<int> selectSort(vector<int> arr){ 7 8 for(vector<int>::iterator i = arr.
阅读全文
摘要:1 #include <bits/stdc++.h> 2 using namespace std; 3 4 void bubbleSort(int a[],int n){ 5 for(int i=0;i<n;i++){ 6 for(int j=0;j<n;j++){ 7 if(a[j]>a[j+1]
阅读全文
摘要:1 #include <iostream> 2 using namespace std; 3 4 int ans=0; 5 const int N = 8; 6 int a[N][N]={0}; 7 8 void show(){ 9 cout<<"answer:"<<ans<<endl; 10 fo
阅读全文
浙公网安备 33010602011771号