编写自己的C++头文件
2013-05-10 07:50
211 查看
// 9_1.cpp : 定义控制台应用程序的入口点。
//
//定义COODIN头文件
#ifndef COORDIN_H_
#define COORDIN_H_
struct polar
{
double distance;
double angle;
};
struct rect
{
double x;
double y;
};
polar rect_to_polar(rect xypos);
void show_polar(polar dapos);
#endif
9_1_2文件
#include"stdafx.h"
#include<iostream>
#include<cmath>
#include"coordin.h"
polar rect_to_polar(rect xypos)
{
using namespace std;
polar answer;
answer.distance=sqrt(xypos.x*xypos.x+xypos.y*xypos.y);
answer.angle=atan2(xypos.y,xypos.x);
return answer;
}
void show_polar(polar dapos)
{
using namespace std;
const double Red_to_deg=57.29577951;
cout<<"distance="<<dapos.distance;
cout<<",angle="<<dapos.angle*Red_to_deg;
cout<<"degrees\n";
}
9_1文件
// 9_1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include"coordin.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
int main()
{
rect rplace;
polar pplace;
cout<<"Enter the x and y value:";
while(cin>>rplace.x>>rplace.y)
{
pplace=rect_to_polar(rplace);
show_polar(pplace);
cout<<"Next two numbers (q to quit):";
}
cout<<"Bye!\n";
return 0;
}
//
//定义COODIN头文件
#ifndef COORDIN_H_
#define COORDIN_H_
struct polar
{
double distance;
double angle;
};
struct rect
{
double x;
double y;
};
polar rect_to_polar(rect xypos);
void show_polar(polar dapos);
#endif
9_1_2文件
#include"stdafx.h"
#include<iostream>
#include<cmath>
#include"coordin.h"
polar rect_to_polar(rect xypos)
{
using namespace std;
polar answer;
answer.distance=sqrt(xypos.x*xypos.x+xypos.y*xypos.y);
answer.angle=atan2(xypos.y,xypos.x);
return answer;
}
void show_polar(polar dapos)
{
using namespace std;
const double Red_to_deg=57.29577951;
cout<<"distance="<<dapos.distance;
cout<<",angle="<<dapos.angle*Red_to_deg;
cout<<"degrees\n";
}
9_1文件
// 9_1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include"coordin.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
int main()
{
rect rplace;
polar pplace;
cout<<"Enter the x and y value:";
while(cin>>rplace.x>>rplace.y)
{
pplace=rect_to_polar(rplace);
show_polar(pplace);
cout<<"Next two numbers (q to quit):";
}
cout<<"Bye!\n";
return 0;
}
相关文章推荐
- 编写自己的头文件与C++中的c库
- C++编写自己的头文件
- C++ 中编写自己的头文件
- C++系列之基本数据类型、常量、变量、const、引用、typedef、枚举、类类型、编写自己的头文件
- 怎样编写自己的C++头文件
- Linux下c++调用自己编写的matlab函数:通过mcc动态链接库.so实现
- 编写自己的C语言头文件
- 编写自己的头文件
- C++中定义自己的头文件
- 用C#(C++)Socket后台编写自己的IIS服务器代替IIS
- Linux下c++调用自己编写的matlab函数:通过mcc动态链接库.so实现
- 编写自己的C语言头文件
- 如何在ROS下编写自己的节点来订阅话题(C++)
- C++头文件的编写--类在头文件中的写法
- 自己动手编写c++事件模型
- c++中STL怎样编写自己的函数对象
- 如何自己编写Arduino支持的C++类库
- 通过gr-modtool在gnuradio中编写自己的C++模块
- c++ 编写自己的小型游戏开发库
- C++头文件里编写实现代码