- 博客(12)
- 收藏
- 关注
原创 放苹果(递归)
#include<bits/stdc++.h> using namespace std; int pl(int m,int n) { if(m==1||n==1||m==0) { return 1; } else { if(m<n) { return pl(m,m); } else { return pl(m-n,n)+pl(m,n-1); } } } int main() { ...
2019-05-09 20:39:43
427
原创 递归(汉诺塔)
#include<bits/stdc++.h> using namespace std; int a[10000]; void s( char yuan, char mudi, char linshi, int n){ if(n==1) cout << yuan << "->" << 1 << "->"<...
2019-04-27 17:08:29
187
原创 递归(斐波那契数列)效率更高
#include<bits/stdc++.h> using namespace std; int a[10000]; int s(int n){ if( a[n] != 0 ) return a[n]; if(n==1 || n==2) return 1; else { { int ans = s(n-1)+s(n-2); a[n] = ans; retu...
2019-04-27 16:42:31
423
原创 递归(斐波那契数列)
#include<bits/stdc++.h> using namespace std; int s(int n){ if(n==1 || n==2) return 1; else { return s(n-1)+s(n-2); } } int main( ){ int fei; cin>> fei; while(fei--){ int num;...
2019-04-27 16:20:39
207
原创 递归easy
#include<bits/stdc++.h> using namespace std; int f(int n){ if (n==1) return 1; else return f(n-1) + n; } int main( ){ cout << f(10); return 0; } 递归
2019-04-20 19:09:01
129
转载 函数传址(调用)
#include<bits/stdc++.h> using namespace std; void swap(int &x,int &y){ int temp; temp = x; x = y; y =temp; cout << x << " " << y <<endl; } int main( ){ in...
2019-04-20 18:43:08
503
原创 函数传值(调用)
#include<bits/stdc++.h> using namespace std; void swap(int x,int y){ int temp; temp = x; x = y; y =temp; cout << x << " " << y <<endl; } int main( ){ int a = 10 ,...
2019-04-20 18:41:26
484
原创 甲流病人初筛
#include<bits/stdc++.h> using namespace std; bool panduan(double tiwen,int ke) { return (tiwen>=37.5&&ke==1); } int main( ){ int sum=0; int n; cin>>n; for(int i=1; i<=n...
2019-04-18 20:28:39
2243
1
原创 素数对
#include<bits/stdc++.h> using namespace std; bool iszhi(int n){ bool falg=true; for(int i=2;i<n;i++) { if(n%i==0){ falg=false; break; } } return falg; } in...
2019-04-13 15:48:34
174
原创 统计素数
#include<bits/stdc++.h> using namespace std; bool zs(int n){ bool flag = true; for( int i=2;i<=n-1;i++){ if( n%i ==0) { flag=false; break; } } return flag; } ...
2019-03-30 17:05:01
654
原创 统计闰年
#include<bits/stdc++.h> using namespace std; bool rn(int n){ if( ( n % 4 == 0) && ( n % 100 != 0) || ( n % 400 == 0)) return true; else return false; } int main( ){ int x,y,t=0; cin ...
2019-03-30 16:08:15
972
原创 函数
#include<bits/stdc++.h> using namespace std; double area(double a,double b,double c){ double p=(a+b+c)/2; return sqrt(p*(p-a)*(p-b)*(p-c)); } int main( ){ cout<<area(3,4,5)+area(5,8,12)...
2019-03-26 21:05:27
177
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅