Advertisement
dmzem

Untitled

Dec 12th, 2022
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <math.h>
  4. #define _USE_MATH_DEFINES
  5.  
  6. using namespace std;
  7.  
  8. void perimeter(float dar){
  9.     cout << "Dlina okruzhnosti: " << 2*M_PI*dar << endl;
  10. }
  11.  
  12. void perimeter(float a, float b){
  13.     float c = a + b + sqrt(b*b + a*a);
  14.     cout << "Perimetr pryamougol'nogo treugol'nika po dvum katetam: " << c << endl;
  15. }
  16.  
  17. void fileReader(){
  18.     cout << "Vso soderzhimoye fayla Text.txt:" << endl;
  19.     ifstream file("File.txt");
  20.     while(!file.eof()){
  21.         string s;
  22.         getline(file,s);
  23.         cout << s << endl;
  24.     }
  25. }
  26.  
  27. void fileReader(int line){
  28.     cout << "Tol'ko " << line << "-ya stroka iz fayla Text.txt:" << endl;
  29.     ifstream file("File.txt");
  30.     string s;
  31.     for(int i = 0; i < line; ++i)
  32.         getline(file, s);
  33.  
  34.    getline(file,s);
  35.    cout << s << endl;
  36. }
  37.  
  38. int main()
  39. {
  40.     cout<<"Zemlyakov" << endl;
  41.     perimeter(5.5);
  42.     perimeter(3, 4);
  43.     fileReader();
  44.     fileReader(5);
  45.     return 0;
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement