Advertisement
josiftepe

Untitled

Nov 25th, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5. int n;
  6. scanf("%d", &n);
  7.  
  8. for(int i = 1; i <= n; i++) {
  9. int r, g, b;
  10. scanf("%d%d%d", &r, &g, &b);
  11. if(r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) {
  12. int maksimum = 0;
  13. if(r > maksimum) {
  14. maksimum = r;
  15. }
  16. if(g > maksimum) {
  17. maksimum = g;
  18. }
  19. if(b > maksimum) {
  20. maksimum = b;
  21. }
  22. if(r == maksimum) {
  23. printf("%d ", r);
  24. }
  25. else {
  26. printf("0 ");
  27. }
  28. if(g == maksimum) {
  29. printf("%d ", g);
  30. }
  31. else {
  32. printf("0 ");
  33. }
  34. if(b == maksimum) {
  35. printf("%d ", b);
  36. }
  37. else {
  38. printf("0 ");
  39. }
  40. printf("\n");
  41.  
  42.  
  43. }
  44. }
  45. }
  46. /**
  47. 5
  48. 200 100 30
  49. 255 123 255
  50. 100 100 100
  51. 300 120 8
  52. 40 80 255
  53. */
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement