Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int V[10][10];
- int V2[10][10];
- int K[10][10];
- void Ilg (int i);
- using namespace std;
- int main () {
- ifstream fd("Duomenys.txt");
- ofstream fr("Rezultatai.txt", ios::app);
- int i = 1, n = 1;
- char a[256];
- string temp;
- while (!fd.eof()){
- fd >> V[i][1] >> V[i][2] >> V[i][3] >> V[i][4];
- Kord(i);
- //cout << V[i][1] << V[i][2] << V[i][3] << V[i][4] << endl;
- i++;
- }
- Ilg(i);
- return 0;
- }
- void Kord(int i) {
- ifstream fd("Duomenys.txt");
- ofstream fr("Rezultatai.txt", ios::app);
- //cout << "labas";
- for (int j = 1; j <= i; j++) {
- // iekau x1 y1
- V2[j][1] = V[j][3];
- V2[j][2] = V[j][2];
- // ieskau x3 y3
- V2[j][3] = V[j][1];
- V2[j][4] = V[j][4];
- cout << "X1 Y1 - " << V2[j][1] << " " << V2[j][2] << endl;
- cout << "X2 Y2 - " << V[j][1] << " " << V[j][2] << endl;
- cout << "X3 Y3 - " << V2[j][3] << " " << V2[j][4] << endl;
- cout << "X4 Y4 - " << V[j][3] << " " << V2[j][4] << endl;
- Ilg(i);
- fr << j << " Trikampio kooridinates" << endl;
- fr << "X1 Y1 - " << V2[j][1] << " " << V2[j][2] << endl;
- fr << "X2 Y2 - " << V[j][1] << " " << V[j][2] << endl;
- fr << "X3 Y3 - " << V2[j][3] << " " << V2[j][4] << endl;
- fr << "X4 Y4 - " << V[j][3] << " " << V2[j][4] << endl;
- }
- }
- void Ilg(int i) {
- ofstream fr("Rezultatai.txt", ios::app);
- for (int j = 1; j < i; j++) {
- K[j][1] = sqrt(pow((double)V[j][1]-(double)V2[j][1],2) + (pow((double)V[j][2] - (double)V2[j][2],2)));
- K[j][2] = sqrt(pow((double)V[j][3]-(double)V2[j][1],2) + (pow((double)V[j][4] - (double)V2[j][2],2)));
- cout << j << " trikampio krastiniu ilgiai " << K[j][1] << " " << K[j][1] << endl;
- fr << j << " trikampio krastiniu ilgiai" << endl;
- fr << K[j][1] << " " << K[j][2] << endl;
- fr << "perimetras = " << K[j][1]*2 + K[j][2]*2;
- }
- fr.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement