Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

I adapted most of the suggestions from answers for my previous question Printing all the permutations of a string in alphabetical order Printing all the permutations of a string in alphabetical order to rewrote my solution again. Please let me know any more changes required or any more suggestions.

#include <iostream>
#include<fstream>
#include<algorithm>
#include<string>
void create_permute( std::string& record )
{
 std::sort( record.begin(), record.end() );
 std::cout<<record;
 
 while( std::next_permutation( record.begin(), record.end() ) )
 { 
 std::cout<<","<<record; 
 } 
 std::cout << "\n"; 
}
void readInputFile( std::string filename ) 
{ 
 std::ifstream infile(filename);
 std::string record;
 while( std::getline( infile,record ) )
 { 
 create_permute( record );
 }
 infile.close();
}
 
int main( int argc, char* argv[] )
{
 if( argc < 2 )
 {
 std::cout << "usage: filesize filename" << "\n";
 exit( 0 );
 }
 std::ios_base::sync_with_stdio( false );
 readInputFile( argv[ 1 ] ); 
 
 return 0;
}

I adapted most of the suggestions from answers for my previous question Printing all the permutations of a string in alphabetical order to rewrote my solution again. Please let me know any more changes required or any more suggestions.

#include <iostream>
#include<fstream>
#include<algorithm>
#include<string>
void create_permute( std::string& record )
{
 std::sort( record.begin(), record.end() );
 std::cout<<record;
 
 while( std::next_permutation( record.begin(), record.end() ) )
 { 
 std::cout<<","<<record; 
 } 
 std::cout << "\n"; 
}
void readInputFile( std::string filename ) 
{ 
 std::ifstream infile(filename);
 std::string record;
 while( std::getline( infile,record ) )
 { 
 create_permute( record );
 }
 infile.close();
}
 
int main( int argc, char* argv[] )
{
 if( argc < 2 )
 {
 std::cout << "usage: filesize filename" << "\n";
 exit( 0 );
 }
 std::ios_base::sync_with_stdio( false );
 readInputFile( argv[ 1 ] ); 
 
 return 0;
}

I adapted most of the suggestions from answers for my previous question Printing all the permutations of a string in alphabetical order to rewrote my solution again. Please let me know any more changes required or any more suggestions.

#include <iostream>
#include<fstream>
#include<algorithm>
#include<string>
void create_permute( std::string& record )
{
 std::sort( record.begin(), record.end() );
 std::cout<<record;
 
 while( std::next_permutation( record.begin(), record.end() ) )
 { 
 std::cout<<","<<record; 
 } 
 std::cout << "\n"; 
}
void readInputFile( std::string filename ) 
{ 
 std::ifstream infile(filename);
 std::string record;
 while( std::getline( infile,record ) )
 { 
 create_permute( record );
 }
 infile.close();
}
 
int main( int argc, char* argv[] )
{
 if( argc < 2 )
 {
 std::cout << "usage: filesize filename" << "\n";
 exit( 0 );
 }
 std::ios_base::sync_with_stdio( false );
 readInputFile( argv[ 1 ] ); 
 
 return 0;
}
Source Link
Steephen
  • 1.3k
  • 13
  • 22

Printing all the permutations of a string in alphabetical order-ver1.1

I adapted most of the suggestions from answers for my previous question Printing all the permutations of a string in alphabetical order to rewrote my solution again. Please let me know any more changes required or any more suggestions.

#include <iostream>
#include<fstream>
#include<algorithm>
#include<string>
void create_permute( std::string& record )
{
 std::sort( record.begin(), record.end() );
 std::cout<<record;
 
 while( std::next_permutation( record.begin(), record.end() ) )
 { 
 std::cout<<","<<record; 
 } 
 std::cout << "\n"; 
}
void readInputFile( std::string filename ) 
{ 
 std::ifstream infile(filename);
 std::string record;
 while( std::getline( infile,record ) )
 { 
 create_permute( record );
 }
 infile.close();
}
 
int main( int argc, char* argv[] )
{
 if( argc < 2 )
 {
 std::cout << "usage: filesize filename" << "\n";
 exit( 0 );
 }
 std::ios_base::sync_with_stdio( false );
 readInputFile( argv[ 1 ] ); 
 
 return 0;
}
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /