Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // LB22_1.cpp: главный файл проекта.
- #include "stdafx.h"
- using namespace System;
- using namespace System::IO;
- void CreateFile( String ^fname )
- {
- String ^street, ^number, ^surn, ^date, ^dolg;
- do {
- Console::Write("\nВведите улицу: ");
- street = Console::ReadLine();
- if( street != "" )
- {
- Console::Write("Введите номер дома: ");
- number = Console::ReadLine();
- Console::Write("Введите фамилию жильца: ");
- surn = Console::ReadLine();
- Console::Write("Введите дату оплаты: ");
- date = Console::ReadLine();
- Console::Write("Введите сумму долга: ");
- dolg = Console::ReadLine();
- File::AppendAllText(fname, String::Format("{0}\t{1}\t{2}\t{3}\t{4}\n", street, number, surn, date, dolg));
- }
- } while( street != "" );
- }
- void ViewFile( String ^fname )
- {
- Console::WriteLine("\nПросмотр файла");
- Console::WriteLine(File::ReadAllText(fname));
- }
- void Ved( String ^fname )
- {
- String ^s;
- StreamReader ^f = File::OpenText(fname);
- array<Char> ^sep = {' ', '\t'};
- Console::WriteLine("Должники:");
- try {
- while( s = f->ReadLine() )
- {
- array<String^> ^subs = s->Split(sep, StringSplitOptions::RemoveEmptyEntries);
- DateTime d = DateTime::Parse(subs[3]);
- int n=d.Month; // 12.31.2014
- Console::WriteLine("DEBUG: "+d.Date+", Month: "+n);
- if( (Convert::ToInt32(subs[4]) >= 500) && DateTime::Now.Month-n >= 3)
- Console::WriteLine(String::Format("{0}\t{1}\t{2}\t{3}\t{4}", subs[0], subs[1], subs[2], subs[3], subs[4]));
- }
- } finally{ f->Close(); }
- }
- int main(array<System::String ^> ^args)
- {
- String ^s = "Belyaev.txt";
- Console::WriteLine("Введите данные для записи в файл. В конце 2 раза нажмите Enter.");
- CreateFile(s);
- ViewFile(s);
- Ved(s);
- Console::Read();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment