Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(int argc, char* argv[])
- {
- float a1, a2, b1, b2, x, y;
- if(argc>4) {
- a1 = (float)atof(argv[1]);
- a2 = (float)atof(argv[3]);
- b1 = (float)atof(argv[2]);
- b2 = (float)atof(argv[4]);
- cout << endl << "Prvi pravac: y = " << a1 << "*x + " << b1 << endl;
- cout << endl << "Drugi pravac: y = " << a2 << "*x + " << b2 << endl;
- }
- else if(argc==4) {
- a1 = (float)atof(argv[1]);
- a2 = (float)atof(argv[3]);
- b1 = (float)atof(argv[2]);
- cout << "Unesite koeficijent b2: ";
- cin >> b2;
- cout << endl << "Prvi pravac: y = " << a1 << "*x + " << b1 << endl;
- cout << endl << "Drugi pravac: y = " << a2 << "*x + " << b2 << endl;
- }
- else if(argc==3) {
- a1 = (float)atof(argv[1]);
- cout << "Unesite koeficijent a2: ";
- cin >> a2;
- b1 = (float)atof(argv[2]);
- cout << "Unesite koeficijent b2: ";
- cin >> b2;
- cout << endl << "Prvi pravac: y = " << a1 << "*x + " << b1 << endl;
- cout << endl << "Drugi pravac: y = " << a2 << "*x + " << b2 << endl;
- }
- else if(argc==2) {
- a1 = (float)atof(argv[1]);
- cout << "Unesite koeficijent b1: ";
- cin >> b1;
- cout << "Unesite koeficijent a2: ";
- cin >> a2;
- b1 = (float)atof(argv[2]);
- cout << "Unesite koeficijent b2: ";
- cin >> b2;
- cout << endl << "Prvi pravac: y = " << a1 << "*x + " << b1 << endl;
- cout << endl << "Drugi pravac: y = " << a2 << "*x + " << b2 << endl;
- }
- else if (argc == 1) {
- cout << "Unesite koeficijent a1: ";
- cin >> a1;
- cout << "Unesite koeficijent b1: ";
- cin >> b1;
- cout << endl << "Prvi pravac: y = " << a1 << "*x + " << b1 << endl;
- cout << "Unesite koeficijent a2: ";
- cin >> a2;
- cout << "Unesite koeficijent b2: ";
- cin >> b2;
- cout << endl << "Drugi pravac: y = " << a2 << "*x + " << b2 << endl;
- }
- if (a1 == a2)
- {
- cout << "Pravci se ne sijeku ";
- if (b1 == b2)
- {
- cout << " – radi se o istom pravcu!" << endl;
- }
- else
- {
- cout << " – radi se o paralelnim pravcima!" << endl;
- }
- }
- else
- {
- cout << "Pravci se sijeku – koordinate sjedišta:" << endl;;
- x = (b2 - b1) / (a1 - a2);
- y = a1 * x + b1;
- cout << " (x,y) = " << x << "," << y << ")" << endl;
- }
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement