| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 683 人关注过本帖
标题:一块来讨论下
取消只看楼主 加入收藏
T_MACC
Rank: 4
等 级:业余侠客
威 望:8
帖 子:99
专家分:211
注 册:2015-4-14
结帖率:83.33%
收藏
已结贴  问题点数:20 回复次数:0 
一块来讨论下
一块来讨论下  


#include "iostream"
#include "math.h"
using namespace std;
typedef struct
{
    double x,y;
}fin;
class Point
{
public:
    friend class Line;
    void fun(int q,int h,int i,int u);
    /oid ha (int q,int h,int i,int u);
private:
    float d;
    int x,y,o,p;
   
};

void Point ::fun(int  q,int h,int i,int u)
{
    x=q;
    y=h;
    o=i;
    p=u;
    cout << "坐标位置是x,y" << "(" <<x <<" "  <<  y << ")"<< endl;
    cout << "坐标位置是o,p" << "(" <<o <<" "  <<  p << ")"<< endl;
    d=sqrt(o*o+p*p);
    printf("距离原点%.2f\n",d);//cout << "距离远点距离是" << d << endl;
}


class Line
{
public:
    void function(int m,int n);
    void aiya (int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3);
private:
    float d1;//距离
    float k1,k2;//斜率
    float k;
    Point T_mac;
   
};
void Line ::function(int m,int n)
{
    cout << "坐标位置是a,b" << "(" <<m <<" "  <<  n << ")"<< endl;
    int a,b,c;
    int y=0,x=0;
    cout << "输入直线参数" << endl;
    cin >> a >> b >> c ;
    //float d;
    y=abs(m*a+n*b-c);
    x=sqrt (a*a+b*b);
    d1=y/x;
    printf("ju li shi %.2lf\n",d1);
    k=a%b;
    if (k>0)
    {
        cout << a << "/" << b << endl;
    }
    else if (k==0)
    {
        printf("%d\n",a/b);
    }
    else if (k<0)
    {
        cout << "-"<<  a << "/" << b << endl;
    }
   
}
void Line ::aiya (int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
{
    double m=0 ,n=0;
    //printf("%dx+%dy+%d==0,%dx+%dy+%d==0",a,b,l,g,h,j);
    k1=(y0-y1)/(x0-x1);
    k2=(y2-y3)/(x2-x3);
    if ((-1)==k1*k2)
    {
        cout << "两直线垂直" << endl ;
    }
    else if (k1==k2)
    {
        cout << "两直线平行 " << endl;
    }
    else if (k1!=k2)
    {
        cout << "两直线橡胶"<< endl;
        m=(k1*x0-k2*x2+y2-y0)/(k1-k2);
        n=y0+(m-x0)*k1;
        printf("焦点是%.2lf %.2lf\n",m,n);
}
void st()
{
    Point point;
   
    int a,b;
    int i,u;
    cin >> a >> b>> i>> u ;
    point.fun(a,b,i,u);
    int c,f;
    cout << "输入需要移动的x y的距离" << endl;
    cin >> c >> f;
    a+=c;
    b+=f;
        point.fun(a,b,i,u);            
        
}
void sp()
{
    Line line;
    int m,n;
    cout << "输入点";
    cin >> m>> n;
    line.function (m,n);
    int x0,y0,x1,y1,x2,y2,x3,y3;
    cout << "shu ru liang tiao zhi xian de can shu "<< endl;
    cin >>x0>> y0>> x1>>y1>> x2>>y2>>x3 >> y3  ;
    line.aiya (x0,y0,x1,y1,x2,y2,x3,y3);
}
int  main()
{
    st ();

    sp ();
    return 0;
}


这段代码    没有在函数被内部定义函数啊    为神魔会  报错呢  
错误信息  
error C2601: 'st' : local function definitions are illegal
F:\编程\c++\aiyou\shiyan.cpp(110) : error C2601: 'sp' : local function definitions are illegal
F:\编程\c++\aiyou\shiyan.cpp(122) : error C2601: 'main' : local function definitions are illegal
F:\编程\c++\aiyou\shiyan.cpp(128) : fatal error C1004: unexpected end of file found
搜索更多相关主题的帖子: private include public double friend 
2015-04-27 15:22
快速回复:一块来讨论下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015513 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved