H3xoR Posted February 24, 2012 Report Share Posted February 24, 2012 (edited) Un mic challenge, utilizand o metoda recursiva. Inversati elementele egal departate de extremitatiile unui vector.Raspunsuri prin PM.Solvers: skull, totti93, cmiN, Sega.Challenge terminat!!!O metoda scrisa de mine( cea mai usoara din toate cele vazute ):#include <iostream>using namespace std;void Reverse( int a[], int n ){ if( n / 2 ) { int aux = *a; *a = a[n-1]; a[n-1] = aux; Reverse( a + 1, n - 2 ); }}int main( void ){ int a[20], n; cout << "n = ", cin >> n; for( int i = 0; i < n; i++ ) cout << "a[" << i << "] = ", cin >> a[i]; Reverse( a, n ); for( int i = 0; i < n; i++ ) cout << a[i] << ' '; return 0;} Edited February 24, 2012 by H3xoR Quote Link to comment Share on other sites More sharing options...
totti93 Posted February 24, 2012 Report Share Posted February 24, 2012 Ai PM! Quote Link to comment Share on other sites More sharing options...
Sega Posted February 24, 2012 Report Share Posted February 24, 2012 Ti-am trimis PM.Mai nou asa se rezolva tema? O transformi in challenge? Quote Link to comment Share on other sites More sharing options...