
C++基础学习
yoyoshaoye
这个作者很懒,什么都没留下…
展开
-
值调用和引用调用(7)
注意:声明一个引用时,必须同时进行初始化,使它只想一个已存在的一个对象引用初始化后,不可只想其他对象#include using namespace std;//值调用void Swap(int a,int b){ int t; t=a; a=b; b=t;}//引用调用:相当于实参的别名,就是C#中的对象调用一样void SwapEx(in原创 2012-01-01 23:22:40 · 478 阅读 · 0 评论 -
数字换位置(2)
#include using namespace std;int main(){ int num;//要反转的数字 int remainder;//余数 cout cin>>num; cout do { remainder=num%10;//取得余数 cout num/=10; } while(num!=0); cou原创 2011-12-31 22:35:23 · 489 阅读 · 0 评论 -
移动汉诺塔(6)
#include using namespace std;void Move(char x,char y){ cout"}//递归调用:JKH分别为3科柱子void hanol(int n,char j,char k,char h){ if(n==1) Move(j,h); else { //将A上的n-1个移动到B上,借助C //将A原创 2012-01-01 23:05:38 · 2344 阅读 · 0 评论 -
内联函数(8)
#include using namespace std;/*内联函数 内联函数在编译时将函数体嵌入在每一个调用处. 主义: 不用在循环和switch语句中 必须出现在第一次调用之前 不能进行一场接口声明 若是内联函数代码多,逻辑复杂,编译器会将该函数自动处理为普通函数*/inline bool IsEqual(int a,int b){ if(a=原创 2012-01-01 23:37:21 · 410 阅读 · 0 评论 -
C++学习(1)
#include using namespace std;int main(){ int inputYear;//存放输入的年份 bool IsLeapYear; cout cin>>inputYear; IsLeapYear=((inputYear%4==0&&inputYear%100!=0)||inputYear%400==0); if(IsLeapYea原创 2011-12-31 21:39:58 · 420 阅读 · 0 评论 -
while循环控制输入(3)
#include using namespace std;int main(){ char m; cout cout cin>>m; while((m!='Y' || m!='y')||(m!='N' || m!='n')) { cout cin>>m; if(m=='Y' || m=='y') { cout bre原创 2011-12-31 23:37:30 · 1030 阅读 · 0 评论 -
求一个二进制数的十进制(4)
//这样的代码只能计算8位二进制,我也改不出来,你妹#include using namespace std;double Transfer(double x,int n){ double val=1.0; while(n--) val*=x; return val;}int main(){ char key;//二进制数 int value=原创 2012-01-01 20:58:20 · 495 阅读 · 0 评论 -
取回文(5)
#include using namespace std;int main(){ bool GetPalindromes(long x);//申明函数 for(long y=11;y { if(GetPalindromes(y)&&GetPalindromes(y*y)&&GetPalindromes(y*y*y)) cout } cout cin原创 2012-01-01 22:45:29 · 359 阅读 · 0 评论