Re: Problem in Coverting CPP code to PHP code?



On May 18, 8:37 am, dgajjanathu...@xxxxxxxxx wrote:
Hi,

this is my CPP code which i want to convert to PHP

#include <iostream>
#include <string>
#include <sstream>
#include <set>
#include<stdio.h>
#include<conio.h>

void print_combinations( std::string prefix, const int* arr,
std::size_t N,
                         std::size_t start, std::size_t num_comb, bool
first_time = true )
{
   static std::set< std::string > prefixes ;
   if( first_time ) prefixes.clear() ;

   if( num_comb == 1 )
   {
       if( prefixes.insert(prefix).second )
       for( std::size_t i = start ; i < N ; ++i )
       {
           std::cout << prefix << arr[i] << '\n' ;
       }
   }
   else
   {

       std::string pref ;
       for( std::size_t i = start ; i < N - num_comb + 1 ; ++i )
           for( std::size_t j = i  ; j < N - num_comb + 2 ; ++j )
           {
               {
                   std::ostringstream stm( prefix ) ;
                   stm << prefix << arr[j] << " + "  ;
                   pref = stm.str() ;
               }
               print_combinations( pref, arr, N, j+1, num_comb-1,
false ) ;
           }
   }

}

int main()
{
  int arr[] = {9, 6, 3, 2} ;
  enum { N = sizeof(arr) / sizeof( arr[0] ) } ;

  for( int num_comb = 1 ; num_comb <= N ; ++num_comb )
      print_combinations( "", arr, N, 0, num_comb ) ;
      getch();

}

Please help me in solving my problem ?
how to do this??

What line(s) specifically are you having trouble with?

.



Relevant Pages

  • Problem in Coverting CPP code to PHP code?
    ... this is my CPP code which i want to convert to PHP ... std::string pref; ... Please help me in solving my problem? ...
    (comp.lang.php)
  • Re: phpmyadmin
    ... I just don't really understand what is going on as the same server will serve up other php pages, but phpmyadmin seems only able to serve html pages. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". ... Trouble? ...
    (Debian-User)
  • Re: phpmyadmin
    ... I just don't really understand what is going on as the same server will serve up other php pages, but phpmyadmin seems only able to serve html pages. ... For example configuration ... Trouble? ...
    (Debian-User)
  • Re: phpmyadmin
    ... I just don't really understand what is going on as the same server will serve up other php pages, but phpmyadmin seems only able to serve html pages. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". ... Trouble? ...
    (Debian-User)
  • Re: phpmyadmin
    ... I just don't really understand what is going on as the same server will serve up other php pages, but phpmyadmin seems only able to serve html pages. ... This was a fresh Apache and phpmyadmin install and it has done this since I installed it. ... Trouble? ...
    (Debian-User)