VXP

Untitled

VXP
Nov 11th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.89 KB | None | 0 0
  1. // LB22_1.cpp: главный файл проекта.
  2.  
  3. #include "stdafx.h"
  4.  
  5. using namespace System;
  6. using namespace System::IO;
  7.  
  8. void CreateFile( String ^fname )
  9. {
  10.     String ^street, ^number, ^surn, ^date, ^dolg;
  11.     do {
  12.         Console::Write("\nВведите улицу: ");
  13.         street = Console::ReadLine();
  14.         if( street != "" )
  15.         {
  16.             Console::Write("Введите номер дома: ");
  17.             number = Console::ReadLine();
  18.             Console::Write("Введите фамилию жильца: ");
  19.             surn = Console::ReadLine();
  20.             Console::Write("Введите дату оплаты: ");
  21.             date = Console::ReadLine();
  22.             Console::Write("Введите сумму долга: ");
  23.             dolg = Console::ReadLine();
  24.             File::AppendAllText(fname, String::Format("{0}\t{1}\t{2}\t{3}\t{4}\n", street, number, surn, date, dolg));
  25.         }
  26.     } while( street != "" );
  27. }
  28. void ViewFile( String ^fname )
  29. {
  30.     Console::WriteLine("\nПросмотр файла");
  31.     Console::WriteLine(File::ReadAllText(fname));
  32. }
  33. void Ved( String ^fname )
  34. {
  35.     String ^s;
  36.     StreamReader ^f = File::OpenText(fname);
  37.     array<Char> ^sep = {' ', '\t'};
  38.     Console::WriteLine("Должники:");
  39.     try {
  40.         while( s = f->ReadLine() )
  41.         {
  42.             array<String^> ^subs = s->Split(sep, StringSplitOptions::RemoveEmptyEntries);
  43.             DateTime d = DateTime::Parse(subs[3]);
  44.             int n=d.Month; // 12.31.2014
  45.             Console::WriteLine("DEBUG: "+d.Date+", Month: "+n);
  46.             if( (Convert::ToInt32(subs[4]) >= 500) && DateTime::Now.Month-n >= 3)
  47.                 Console::WriteLine(String::Format("{0}\t{1}\t{2}\t{3}\t{4}", subs[0], subs[1], subs[2], subs[3], subs[4]));
  48.         }
  49.     } finally{ f->Close(); }
  50. }
  51.  
  52. int main(array<System::String ^> ^args)
  53. {
  54.     String ^s = "Belyaev.txt";
  55.     Console::WriteLine("Введите данные для записи в файл. В конце 2 раза нажмите Enter.");
  56.     CreateFile(s);
  57.     ViewFile(s);
  58.     Ved(s);
  59.     Console::Read();
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment