fork download
  1. #include<iostream>
  2. using namespace std;
  3. const int N=8;
  4. int szach(int x, int y, int tab[N][N])
  5. {
  6. int wartosc=0;
  7. for(int i=0;i<N;i++)
  8. {
  9. wartosc=wartosc+tab[x][i]+tab[y][i];
  10. }
  11. wartosc=wartosc-2*tab[x][y];
  12.  
  13. return wartosc;
  14. }
  15.  
  16. void suma(int tab[N][N])
  17. {
  18. int MAX=0;
  19. int x1,x2,y1,y2,wartosc;
  20. for(int n=0;n<N*N;n++)
  21. {
  22. x1=n%N;
  23. y1=n/N;
  24. for(int i=(y1+1)*N;i<N*N;i++)
  25. {
  26. x2=i%N;
  27. y2=i/N;
  28. if(y1!=y2)
  29. {
  30. wartosc=szach(x1,y1,tab)+szach(x2,y2,tab)-tab[x1][y2]-tab[x2][y1];
  31. if(wartosc>MAX
  32. }
  33. }
  34. }
  35. }
  36.  
  37. int main()
  38. {
  39. int tab[N][N];
  40. for(int i=0;i<N*N;i++)tab[i/N][i%N]=rand()%1000;
  41. int wynik;
  42. wynik=suma(tab);
  43. return 0;
  44.  
  45. }
  46.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void suma(int (*)[8])’:
prog.cpp:32:13: error: expected ‘)’ before ‘}’ token
             }
             ^
prog.cpp:32:13: error: expected primary-expression before ‘}’ token
prog.cpp: In function ‘int main()’:
prog.cpp:42:19: error: void value not ignored as it ought to be
     wynik=suma(tab);
                   ^
stdout
Standard output is empty