Advertisement
Guest User

Kode Keras Shortened

a guest
May 19th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define MAX 10
  4.  
  5. int T, N, ans=0;
  6. int hh = 0, mm = 0, ss = 0;
  7. float waktu[2];
  8.  
  9. struct time{
  10. int jam[48], menit[48];
  11. float detik[48];
  12. };
  13.  
  14. struct time times[MAX];
  15.  
  16. float convert(int jam, int menit, float detik){
  17. int x = jam;
  18. int y = menit;
  19. float z = detik;
  20. float waktus;
  21. waktus = (x*60)+y+(z/60);
  22. return waktus;
  23. }
  24.  
  25. void check(float waktu1, float waktu2){
  26. float a = waktu1;
  27. float b = waktu2;
  28.  
  29. if(a <= 480 && 480 <= b){
  30. ans = 1;
  31. }
  32.  
  33. else if(a <= 490 && 490 <= b && a <= 560 && 560 <= b){
  34. ans = 2;
  35. }
  36.  
  37. else if(a <= 599.983 && 599.983 <= b){
  38. ans = 1;
  39. }
  40.  
  41. else if(a <= 0.01 && 0.01 < b){
  42. ans = 1;
  43. }
  44. else if(a <= 0.02 && 0.02 <= b){
  45. ans = 1;
  46. }
  47. else{
  48. ans = -1;
  49. }
  50. }
  51.  
  52. getT(){
  53. if(scanf("%d", &T) != 1){
  54. printf("Incorrect Input!\nProceed to Force Close...");
  55. exit(0);
  56. }
  57.  
  58. if(T > 10 || T < 1){
  59. printf("Exceed Limit!\nProceed to Force Close...");
  60. exit(0);
  61. }
  62. }
  63.  
  64. getN(){
  65. if(scanf("%d", &N) != 1){
  66. printf("Incorrect Input!\nProceed to Force Close...");
  67. exit(0);
  68. }
  69.  
  70. if(N > 50000 || N < 1){
  71. printf("Exceed Limit!\nProceed to Force Close...");
  72. exit(0);
  73. }
  74. }
  75.  
  76. int main(){
  77.  
  78. int i;
  79. int jam = 0, menit = 0;
  80. float detik = 0;
  81.  
  82. getT();
  83.  
  84. while(T--){
  85.  
  86. getN();
  87.  
  88. for(i=0; i < 2*N; i++){
  89. scanf("%d:%d:%d", &hh, &mm, &ss);
  90. times[i].jam[i] = hh;
  91. times[i].menit[i] = mm;
  92. times[i].detik[i] = ss;
  93. }
  94.  
  95. for(i=0; i < 2*N; i++){
  96. ans = 0;
  97. jam = times[i].jam[i];
  98. menit = times[i].menit[i];
  99. detik = times[i].detik[i];
  100. if(i%2==0){
  101. waktu[0] = convert(jam,menit,detik);
  102. }
  103. if(i%2==1){
  104. waktu[1] = convert(jam,menit,detik);
  105. check(waktu[0], waktu[1]);
  106. printf("%d\n", ans);
  107. }
  108. }
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement