fork download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. int a[] = {9,8,5,7,6,2,3,4};
  7. int n = sizeof(a)/sizeof(int);
  8. int max = 0, numar = 0, exponent = n-2;
  9. for (int i=0; i<n-1;i++) {
  10. for(int j=0;j<n;j++) {
  11. if ( j==i || j==i+1 ) {
  12. continue;
  13. }
  14. else {
  15. numar += a[j] * pow(10.0, --exponent);
  16. }
  17. }
  18. cout<<numar<<endl;
  19. max = numar > max ? numar : max;
  20. numar = 0;
  21. exponent = n-2;
  22. }
  23. cout<<"max:"<<max;
  24. return 0;
  25. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
576234
976234
986234
985234
985734
985764
985762
max:986234