C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
| #include <cstddef>
#include <ios>
#include <istream>
#include <ostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <iterator>
#include <vector>
::std::string
get_token( ::std::istream & in, ::std::string delim )
{
typedef ::std::char_traits< char > traits;
::std::string ret;
for( traits::int_type cur( in.get( ) ); ( cur != traits::eof( ) ) && in.good( ); cur = in.get( ) )
{
ret.push_back( static_cast< char >( cur ) );
if( delim.find( static_cast< char >( cur ) ) != ::std::string::npos )
break;
}
return( ret );
}
void
reorder( ::std::istream & in, ::std::ostream & out, ::std::size_t limit )
{
::std::vector< ::std::string > head;
for( ; limit != 0; --limit )
head.push_back( ::get_token( in, ".!?" ) );
::std::copy( head.rbegin( ), head.rend( ), ::std::ostream_iterator< ::std::string >( out ) );
out << in.rdbuf( );
}
int
main( int argc, char * * argv )
{
::std::string in_filename( "input.txt" );
::std::string out_filename( "output.txt" );
if( argc > 1 )
in_filename = argv[ 1 ];
if( argc > 2 )
in_filename = argv[ 2 ];
::std::ifstream input( in_filename.c_str( ), ::std::ios::binary );
::std::ofstream output( out_filename.c_str( ), ::std::ios::binary );
::reorder( input, output, 3 );
} |
|
|
Комментарий модератора |
 |
Используйте теги форматирования кода! |
|
Посмотрите пожалуйста эту программу, объясните, что тут не так??? почему когда я input.txt ввожу текст, в output. txt он не отображается??? у меня вообще в принципе при запуске программы, ничего не пишет и ничего не делает