Ir ao conteúdo
  • Cadastre-se

Smith Lacerda

Membro Júnior
  • Posts

    1
  • Cadastrado em

  • Última visita

Reputação

0
  1. Galera, boa tarde. Estou precisando transformar o código abaixo que está em PE (Programação Estruturada) para POO (Programação Orientada a objeto). Ou seja, temos que criar uma classe (um arquivo .h, usar o destrutor e construtotor, set e get) e chamar no #include. em Paralelo, temos que substituir o insert sort por um método bubble sorte. SERÁ QUE ALGUÉM PODE ME AJUDAR ? Segue o código em C++ que deve ser transformado para POO. #include <iostream> #include <cstdlib> #include <ctime> using namespace std ; void buildArray( char [ ] , int ) ; void sortArray( char [ ] , int ) ; void printArray( const char [ ] , int ) ; int main( ) { const int aSize = 20 ; char a[ aSize ] ; buildArray( a , aSize ) ; sortArray( a , aSize ) ; printArray( a , aSize ) ; return 0 ; } void buildArray( char b[ ] , int bSize ) { srand( time( 0 ) ) ; for ( int i = 0 ; i < bSize ; ++i ) b[ i ] = (char)(rand( ) % 95 + 33) ; } void sortArray( char b[ ] , int bSize ) { for ( int j = 1 ; j < bSize ; ++j ) { int ins = b[ j ] ; int mov = j ; while ( ( mov > 0 ) && ( b[ mov - 1 ] > ins ) ) { b[ mov ] = b[ mov - 1 ]; mov--; } b[ mov ] = ins ; } } void printArray( const char b[ ] , int bSize ) { cout << endl ; for ( int i = 0 ; i < bSize ; ++i ) cout << b[ i ] << " " ; cout << endl ; } Código em PE.txt

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...