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


#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
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:7 
#include "iostream"
#include "cmath"
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);
    void ha(int q,int h,int i,int u);
private:
    float d;
    int x,y,o,p;
};
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 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);
    cout<<"距离原点"<<d<<endl;//cout << "距离远点距离是" << d << endl;
}
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;
    cout<<"ju li shi "<<d1<<endl;
    k=a%b;
    if (k>0)
    {
        cout<<a<<"/"<<b<< endl;
    }
    else if(k==0)
    {
        cout<<a/b<<endl;
    }
    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;
        cout<<"焦点是"<<m<<" "<<n<<endl;
    }
}
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;
}

剑栈风樯各苦辛,别时冰雪到时春
2015-04-27 17:15
素还真少爷
Rank: 2
等 级:论坛游民
帖 子:7
专家分:26
注 册:2015-4-27
收藏
得分:7 
怎么没人a ?
2015-04-27 19:08
hzj199603
Rank: 2
来 自:南京
等 级:论坛游民
帖 子:18
专家分:32
注 册:2015-3-29
收藏
得分:7 
回复 楼主 T_MACC
#include "iostream"
#include "math.h"
using namespace std;
class Point
{
public:
    void fun(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;
    }
    if (k==0)
    {
        cout<<a/b<<endl;//printf("%d\n",a/b);
    };
    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;
    float k1,k2;
    //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;
}






#include "iostream"
#include "math.h"
using namespace std;
class Point
{
public:
    friend class Line;
    void fun(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 << "输入两直线参数a,b,c" << endl;
    cin >> a >> b >> c ;
    //float d;
    y=abs(m*a+n*b-c);
    x=sqrt (a*a+b*b);
    d1=y/x;
    printf("距离是 %.2lf\n",d1);
    k=a%b;
    if (k>0)
    {
        cout << a << "/" << b << endl;
    }
    if (k==0)
    {
        cout<<a/b<<endl;//printf("%d\n",a/b);
    };
    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;
    float k1,k2;
    //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;
    cout<<"输入两个点的坐标:";
    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;
    line.aiya (x0,y0,x1,y1,x2,y2,x3,y3);
}
int  main()
{
    st ();
    sp ();
    return 0;
}
2015-05-04 22:06
快速回复:一块来讨论下
数据加载中...
 
   



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

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