equal
deleted
inserted
replaced
1 #include <xy.h> |
1 #include <xy.h> |
2 #include <iostream> |
2 #include <iostream> |
3 using namespace std; |
3 using namespace std; |
4 using namespace hugo; |
4 using namespace hugo; |
|
5 |
|
6 bool passed = true; |
|
7 |
|
8 void check(bool rc) { |
|
9 passed = passed && rc; |
|
10 if(!rc) { |
|
11 cout << "Test failed!" << endl; |
|
12 } |
|
13 } |
|
14 |
|
15 |
|
16 |
5 int main() |
17 int main() |
6 { |
18 { |
7 |
19 |
8 cout << "Kérek szépen egy egész számot!" << endl; |
|
9 int s; |
|
10 cin >> s; |
|
11 |
20 |
12 cout << "Kerek sok sikvektort." << endl; |
|
13 |
21 |
14 xy<int> osszeg; |
22 typedef xy<int> XY; |
15 xy<int> kul; |
23 |
16 xy<int> z; |
24 XY seged; |
|
25 XY a(1,2); |
|
26 XY b(3,4); |
17 |
27 |
18 vector< xy<int> > v; |
28 seged = a+b; |
19 |
29 check(seged.x==4 && seged.y==6); |
20 while(cin >> z) { |
|
21 v.push_back(z); |
|
22 osszeg += z; |
|
23 kul -= z; |
|
24 cout << "Az összeg aktualisan: " << osszeg << endl; |
|
25 cout << "A különbség aktualisan: " << kul << endl; |
|
26 } |
|
27 |
30 |
28 cout << "A kovetkezo szamokat szoroztam ossze:" << endl; |
31 seged = a-b; |
29 for(unsigned int i=0; i<v.size(); ++i) { |
32 check(seged.x==-1 && seged.y==-1); |
30 cout << v[i] << ", A normanégyzete: " << v[i].normSquare() <<endl; |
33 |
31 cout << v[i] << " " << s << " szorosa " << v[i]*s <<endl; |
34 check(a.normSquare()==5); |
32 cout << v[i] << " " << s << " edrésze " << v[i]/s <<endl; |
35 check(a*b==11); |
33 } |
36 |
34 if (v.size()>1){ |
37 int l=2; |
35 cout << "Az elsö kettö szorzata: " << v[0]*v[1] << endl; |
38 seged = a*l; |
36 } |
39 check(seged.x==2 && seged.y==4); |
37 |
40 |
38 cout << "Eleg nehez volt." << endl; |
41 seged = b/l; |
|
42 check(seged.x==1 && seged.y==2); |
|
43 |
|
44 typedef BoundingBox<int> BB; |
|
45 BB doboz1; |
|
46 doboz1 += a; |
|
47 doboz1 += b; |
|
48 |
|
49 cout << (passed ? "All tests passed." : "Some of the tests failed!!!") |
|
50 << endl; |
|
51 |
|
52 return passed ? 0 : 1; |
|
53 |
39 } |
54 } |