Új hozzászólás Aktív témák
-
icespeak
csendes tag
Helló!
A segítségeteket szeretném kérni az alábbi programban. Az lenne a feladat, hogy egy origóból induló vektorral eltoljam a megadott köröket. Megadjuk a vektor végpontját a körök középpontját és a sugaraikat. Csak valamiért nem megy.[B]main.cpp[/B]
#include <iostream>
#include <vector>
#include "read.h"
#include "pont.h"
#include "kor.h"
#include "vektor.h"
#include <string>
using namespace std;
int main()
{
double d,e,r,x,y,u,k;
cout<<"Adja meg a vektort\n";
cout<<"d= "; cin>>d;
cout<<"e= "; cin>>e;
int n=ReadInt("\nKorok szama: ", "Termeszetes szamot varok!");
vector<Kor> t(n);
for(int i=0; i<n;++i)
{
cout<<"Az"<<i+1<<"-dik kor koordinatai:\n";
x=ReadReal("\t x: ", "Valos szamot varok!");
y=ReadReal("\t y: ", "Valos szamot varok!");
Pont c;
c.Beallit(x,y);
r=ReadRealP("A kor sugara: ","Nem negativ valos szamot varok!");
c.Eltol(u,k,d,e);
c.Kiir(u, k);
}
return 0;
}
[B]kor.h[/B]
#ifndef KOR_H_INCLUDED
#define KOR_H_INCLUDED
#include "pont.h"
class Kor{
private:
Pont c;
double r;
public:
};
#endif // KOR_H_INCLUDED
[B]pont.h[/B]
#ifndef PONT_H_INCLUDED
#define PONT_H_INCLUDED
#include "vektor.h"
class Pont{
private:
double x,y;
public:
Pont() {x=y=0.0;}
void Beallit (double a, double b) {x=a; y=b;}
void Eltol(double u, double k, double &a, double &b);
void Kiir(double u, double k);
};
#endif // PONT_H_INCLUDED
[B]vektor.h[/B]
#ifndef VEKTOR_H_INCLUDED
#define VEKTOR_H_INCLUDED
class Vector2D{
private:
double d,e;
public:
Vector2D(): d(0.0), e(0.0) {}
Vector2D(double &a, double &b): d(a), e(b) {}
};
#endif // VEKTOR_H_INCLUDED
[B]pont.cpp[/B]
#include <iostream>
#include "pont.h"
#include "vektor.h"
using namespace std;
void Pont::Eltol(double u, double k, double &a, double &b)
{
u=x+a;
k=y+b;
}
void Pont::Kiir(double u, double k)
{
cout <<"u: "<<u<<endl;
cout <<"k: "<<k<<endl;
}
Új hozzászólás Aktív témák
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!