Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. // lab_3_cw_4.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <fstream>
  7. #include <cmath>
  8. using namespace std;
  9.  
  10.  
  11.  
  12. int _tmain(int argc, _TCHAR* argv[])
  13. {  
  14.     ifstream czytaj("C:\\dane_zad.txt");
  15.     ifstream temp("C:\\dane_zad.txt");
  16.    
  17.     float suma_re=0, suma_im=0, iloczyn_re=1, iloczyn_im=1;
  18.     float a, b, z1,z2;
  19.     float modul, max;
  20.     temp >> z1;
  21.     temp >> z2;
  22.     max=sqrt((z1*z1)+(z2*z2));
  23.     while(!czytaj.eof())
  24.     {
  25.         czytaj >> a;
  26.         suma_re+=a;
  27.         iloczyn_re*=a;
  28.         czytaj >> b;
  29.         suma_im+=b;
  30.         iloczyn_im+=b;
  31.         modul=sqrt((a*a)+(b*b));
  32.         if(modul>max)
  33.         {
  34.             max=modul;
  35.             z1=a;
  36.             z2=b;
  37.         }
  38.     }
  39.     cout << "suma: " <<suma_re<< "+" <<suma_im<< "i" << endl;
  40.     cout << "iloczyn: " <<iloczyn_re<< "+" <<iloczyn_im<< "i" << endl;
  41.  
  42.     cout << "liczba z max modulem: " << z1 << "+" << z2 << "i";
  43.    
  44.     getchar();
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement