Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // lab_3_cw_4.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <fstream>
- #include <cmath>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- ifstream czytaj("C:\\dane_zad.txt");
- ifstream temp("C:\\dane_zad.txt");
- float suma_re=0, suma_im=0, iloczyn_re=1, iloczyn_im=1;
- float a, b, z1,z2;
- float modul, max;
- temp >> z1;
- temp >> z2;
- max=sqrt((z1*z1)+(z2*z2));
- while(!czytaj.eof())
- {
- czytaj >> a;
- suma_re+=a;
- iloczyn_re*=a;
- czytaj >> b;
- suma_im+=b;
- iloczyn_im+=b;
- modul=sqrt((a*a)+(b*b));
- if(modul>max)
- {
- max=modul;
- z1=a;
- z2=b;
- }
- }
- cout << "suma: " <<suma_re<< "+" <<suma_im<< "i" << endl;
- cout << "iloczyn: " <<iloczyn_re<< "+" <<iloczyn_im<< "i" << endl;
- cout << "liczba z max modulem: " << z1 << "+" << z2 << "i";
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement