摘要: 一、代码 1 //输出字符数组奇数位的数,要求使用指针实现 2 #include 3 void main() 4 { 5 int n; 6 cout>n; 8 char *a=new char [n]; 9 for (int i=0;i>a[i];12 }13 char *p=a;14 for(int j=0;j<n;j++)15 if(j%2==0)16 {17 cout<<p[j]<<" ";18 j++;19 }20 delet... 阅读全文
posted @ 2013-09-25 21:41 不懂编程的程序员 阅读(292) 评论(0) 推荐(0) 编辑
摘要: 一、代码 1 /////////////////// 2 /*动态分配数组 3 int *p=new int[size]; 4 .... 5 delete[]p; 6 */ 7 //////用动态数组求斐波那契的前N项 8 #include 9 using namespace std;10 void main()11 {12 int n;13 cout>n;15 cout<<"前"<<n<<"项为:"<<endl;16 int *p=new int[n];//动态生成数组17 if (p==0||p& 阅读全文
posted @ 2013-09-25 15:43 不懂编程的程序员 阅读(517) 评论(0) 推荐(0) 编辑
摘要: 一、代码 1 #include 2 using namespace std; 3 void swap1(int x,int y) 4 { 5 int t=x; 6 x=y; 7 y=t; 8 cout>a>>b;23 cout<<"a和b交换前的值为:a="<<a<<" b="<<b<<endl;24 swap1(a,b);25 swap2(&a,&b);26 cout<<"a和b交换后的值为:a="<<a<&l 阅读全文
posted @ 2013-09-25 15:13 不懂编程的程序员 阅读(1003) 评论(0) 推荐(0) 编辑