#include "stdafx.h"
#include "iostream"
#include "cmath"
using namespace std;
struct polar
{double distance;double angle;};
struct rect
{double x;double y;};
//函数原型,即告诉编译器下面函数的结构是怎样的,比如传递几个参数,每个参数的类型是int还是char等
polar rect_to_polar(rect xypos);
void show_polar(polar dapos);
int main()
{rect rplace;polar pplace;
cout<<"Enter the x and y value:"<<endl;
while(cin>>rplace.x>>rplace.y){
pplace=rect_to_polar(rplace);
show_polar(pplace);
cout<<"next two numbers(q to quit):";
}
cout<<"Done.\n";
return 0;}
polar rect_to_polar(rect xypos)
结构是多个变量的组合体,作用是增加代码的重用性,比如一个结构包含姓名,年龄,身高,它可以应用于每个学生,这就是重用性。
原文:https://www.cnblogs.com/whcsrj/p/12928889.html