HackerRank C- Compare the Triplets



Complete the function compareTriplets in the editor below. It must return an array of two integers, the first being Alice's score and the second being Bob's.

compareTriplets has the following parameter(s):

a: an array of integers representing Alice's challenge rating
b: an array of integers representing Bob's challenge rating



  1. #include<stdio.h>
  2. main()
  3. {
  4. int a[3],b[3],c[2],i,d=0,e=0;
  5. for(i=0;i<3;i++)
  6. {
  7. scanf("%d",&a[i]);
  8. }
  9. for(i=0;i<3;i++)
  10. {
  11. scanf("%d",&b[i]);
  12. }
  13. for(i=0;i<3;i++)
  14. {
  15. if(a[i]>b[i])
  16. {
  17. d++;
  18. }
  19. if(a[i]<b[i])
  20. {
  21. e++;
  22. }
  23. if(a[i]==b[i])
  24. {
  25. printf("");
  26. }
  27. }
  28. printf("%d %d",d,e);
  29. }

download android app