Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define MAX 10
- int T, N, ans=0;
- int hh = 0, mm = 0, ss = 0;
- float waktu[2];
- struct time{
- int jam[48], menit[48];
- float detik[48];
- };
- struct time times[MAX];
- float convert(int jam, int menit, float detik){
- int x = jam;
- int y = menit;
- float z = detik;
- float waktus;
- waktus = (x*60)+y+(z/60);
- return waktus;
- }
- void check(float waktu1, float waktu2){
- float a = waktu1;
- float b = waktu2;
- if(a <= 480 && 480 <= b){
- ans = 1;
- }
- else if(a <= 490 && 490 <= b && a <= 560 && 560 <= b){
- ans = 2;
- }
- else if(a <= 599.983 && 599.983 <= b){
- ans = 1;
- }
- else if(a <= 0.01 && 0.01 < b){
- ans = 1;
- }
- else if(a <= 0.02 && 0.02 <= b){
- ans = 1;
- }
- else{
- ans = -1;
- }
- }
- getT(){
- if(scanf("%d", &T) != 1){
- printf("Incorrect Input!\nProceed to Force Close...");
- exit(0);
- }
- if(T > 10 || T < 1){
- printf("Exceed Limit!\nProceed to Force Close...");
- exit(0);
- }
- }
- getN(){
- if(scanf("%d", &N) != 1){
- printf("Incorrect Input!\nProceed to Force Close...");
- exit(0);
- }
- if(N > 50000 || N < 1){
- printf("Exceed Limit!\nProceed to Force Close...");
- exit(0);
- }
- }
- int main(){
- int i;
- int jam = 0, menit = 0;
- float detik = 0;
- getT();
- while(T--){
- getN();
- for(i=0; i < 2*N; i++){
- scanf("%d:%d:%d", &hh, &mm, &ss);
- times[i].jam[i] = hh;
- times[i].menit[i] = mm;
- times[i].detik[i] = ss;
- }
- for(i=0; i < 2*N; i++){
- ans = 0;
- jam = times[i].jam[i];
- menit = times[i].menit[i];
- detik = times[i].detik[i];
- if(i%2==0){
- waktu[0] = convert(jam,menit,detik);
- }
- if(i%2==1){
- waktu[1] = convert(jam,menit,detik);
- check(waktu[0], waktu[1]);
- printf("%d\n", ans);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement