您的位置:首页 > 其它

CodeBlocks调试功能快捷教程

2015-05-29 15:54 344 查看
在程序设计中,单步调试能够跟踪程序的执行流程。跟踪过程中,还可以观察变量的变化,从而发现其中存在的问题。单步执行除了可以帮助我们发现设计的程序中存在的问题,对于初学者,还可以帮助我们理解语言的机制。

  所以,对于初学者,掌握所用的集成开发环境的一般用法,是一件非常重要的事情。

  由于其重要性,再引用中国的一句古话“工欲善其事,必先利其器”,单步调试就是程序设计者最重要的工具之一,这种工具的形态是软件。程序员用软件当工具,正常得不得了。

  本文介绍CodeBlock的调试功能。因为面向初学者,高手请绕行。到资源中下载,请点链接:http://download.csdn.net/detail/sxhelijian/6541685

  (相关链接——我写的VC++中调试功能:VC++6.0调试工具使用初步















示例代码:

[cpp] view plaincopyprint?

#include <iostream>

using namespace std;

const double pi=3.1415926;

int main( )

{

float r,a;

cout<<"输入半径:"<<endl;

cin>>r;

a=pi*r*r;

cout<<"输出面积:";

cout<<a<<endl;

return 0;

}

float volume(float h,float r)

{

return pi*r*r*h;

}









实践代码:

[cpp] view plaincopyprint?

#include <iostream>

using namespace std;

const double pi=3.1415926;

int main( )

{

int a;

cout<<"请输入一个数:"<<endl;

cin>>a;

if(a = 2)

cout<<"你2了。";

else

cout<<"你不2。";

return 0;

}







示例代码:

[cpp] view plaincopyprint?

#include <iostream>

using namespace std;

const double pi=3.1415926;

float area(float r);

int main( )

{

float r1,a1;

cin>>r1;

a1=area(r1);

cout<<a1<<endl;

return 0;

}

float area(float r)

{

float a;

a = pi*r*r;

return a;

}







实践代码:

[cpp] view plaincopyprint?

#include <iostream>

using namespace std;

float max(float x, float y);

int main ()

{

float a,b,c;

cin>>a>>b;

c=max(a, b) ;

cout<<"The max is "<<c<<endl;

return 0;

}

float max(float x, float y)

{

float z;

z=(x<y)? x : y ;

return z;

}







示例代码:

[cpp] view plaincopyprint?

#include<iostream>

#include<cmath>

using namespace std;

int max(int,int);

int main( )

{

int m,a,b;

a=100;

b=200;

m=max(a,b);

cout<<"最大:"<<m<<endl;

return 0;

}

int max(int x,int y)

{

int z;

if(x>y)

z=x;

else

z=y;

return z;

}





实践代码:

[cpp] view plaincopyprint?

#include <iostream>

using namespace std;

float max(float x, float y);

int main ()

{

float a,b,c;

cin>>a>>b;

c=max(a, b) ;

cout<<"The max is "<<c<<endl;

return 0;

}

float max(float x, float y)

{

float z;

z=(x<y)? x : y ;

return z;

}



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: