程序设计基础知识
算法的特性
算法的复杂度
-时间复杂度 -空间复杂度
c++程序设计
#include <bits/stdc++.h>
using namespace std;
int a(int x){
if (x==1)return 1;
return a(x-1)+x;
}
int main ()
{
int n;
cin>>n;
cout<<n;
return 0;
}
算法的复杂度
时间复杂度
空间复杂度
c++语言基础
数据类型
函数
示例:
例如编写一求1+2+..+n的值,其中n<=20
#include <iostream>
using namespace std;
int add(int n){
if(n==1) {
return 1;
}
return add(n-1) + n;
1 + 2 + 3
}
int main(){
cout << add(4);
return 0;
}