最近学习的简单源码 二
时间:2010-10-13 来源:天佑乐天
- #include "iostream.h"
- void create(int n=100);
- int main()
- {
- create();
- create(45);
- return 0;
- }
- void create(int n)
- {
- cout<<"要创造"<<n<<"个空间"<<endl;
- return;
- }
- #include "iostream.h"
- void swap(int &x,int &y);
- int main()
- {
- int a=2,b=3;
- swap(a,b);
- cout<<"a="<<a<<' '<<"b="<<b<<endl;
- return 0;
- }
- void swap(int &x,int &y)
- {
- int temp;
- temp=x;
- x=y;
- y=temp;
- return;
- }
- #include <iostream>
- using std::cin;
- using std::cout;
- using std::endl;
- int f(int n);
- int main()
- {
- for (int i=1;i<=8;i++)
- {
- cout<<"f(i)="<<f(i)<<endl;
- }
- return 0;
- }
- int f(int n)
- {
- if(n>1) return f(n-1)*2+3;
- return 1;
- }
- #include <iostream>
- using std::cout;
- using std::cin;
- using std::endl;
- int main()
- {
- int array[]={3,5,6,8,7,9};
- int size=sizeof(array)/sizeof(int);
- cout<<"size="<<size<<endl;
- for (int i=0;i<size;i++)
- {
- cout<<array[i]<<' '<<endl;
- }
- return 0;
- }
相关阅读 更多 +