fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. string sprawdz(int arr[]) {
  5. int a = 0;
  6. int sum = 0;
  7.  
  8. for(int i = 0; i < 4; i++) {
  9. int x = arr[i];
  10. a ^= x;
  11. sum += x;
  12. }
  13.  
  14. if (a == 0) {
  15. if (sum == arr[0]*4) {
  16. return "Kwadrat";
  17. } else if (arr[0] == arr[2]) {
  18. return "Prostokąt";
  19. }
  20. }
  21.  
  22. return "Nie-wiadomo-co";
  23. }
  24.  
  25. int main() {
  26. int arr[4] = {2, 6, 6, 2};
  27. cout << endl << sprawdz(arr);
  28. int arra[4] = {2, 6, 2, 6};
  29. cout << endl << sprawdz(arra);
  30. int arrb[4] = {2, 2, 2, 2};
  31. cout << endl << sprawdz(arrb);
  32. int arrc[4] = {2, 2, 2, 6};
  33. cout << endl << sprawdz(arrc);
  34. cout << endl;
  35. return 0;
  36. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Nie-wiadomo-co
Prostokąt
Kwadrat
Nie-wiadomo-co