View Code of Problem 100

#include <stdio.h>
typedef struct{
  char name[30];
  char time[5];
}music;
int main(){
  int  reatime(char a[5]){
  int c[2]={0};
    int time1;
            q=0;
            for(p=0;p<strlen(a);p++)
              if(a[p]==':')
                q++;
              else
                c[q]=c[q]*10+a[p]-'0';
              time1=c[0]*60+c[1];
}
  music s[108];
  int m,n;
  while (scanf("%d",&n)!=EOF){
    if(n==0)
      break;
    int ztime[108];
  	for(i=1;i<=n;i++){
    	scanf("%s %s",&s[i].name,&s[i].time);
          ztime[i]=reatime(s[i].time);
 	 }
    scanf("%d",&m);
    char a[30],b[5];
    for(i=1;i<=10000;i++){
      scanf("%s %s",&a,&b);
      for(j=1;j<=n;j++){
        if(strcmp(s[j].name,a)==0){
          rtime[i]=reatime(a);
          rtime[i]/ztime[j];
        }
      }
    }
  }
  
  
  
  
  
  return 0;
}
/*
Main.c: In function 'reatime':
Main.c:10:13: error: 'q' undeclared (first use in this function)
             q=0;
             ^
Main.c:10:13: note: each undeclared identifier is reported only once for each function it appears in
Main.c:11:17: error: 'p' undeclared (first use in this function)
             for(p=0;p<strlen(a);p++)
                 ^
Main.c:11:13: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
             for(p=0;p<strlen(a);p++)
             ^
Main.c:11:23: warning: incompatible implicit declaration of built-in function 'strlen'
             for(p=0;p<strlen(a);p++)
                       ^
Main.c:9:9: warning: variable 'time1' set but not used [-Wunused-but-set-variable]
     int time1;
         ^
Main.c:17:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
Main.c: In function 'main':
Main.c:24:8: error: 'i' undeclared (first use in this function)
    for(i=1;i<=n;i++){
        ^
Main.c:31:7: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[30]' [-Wformat=]
       scanf("%s %s",&a,&b);
       ^
Main.c:31:7: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'char (*)[5]' [-Wformat=]
Main.c:32:11: error: 'j' undeclared (first use in this function)
       for(j=1;j<=n;j++){
           ^
Main.c:33:9: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]
         if(strcmp(s[j].name,a)==0){
         ^
Main.c:34:11: error: 'rtime' undeclared (first use in this function)
           rtime[i]=reatime(a);
           ^
Main.c:23:9: warning: variable 'ztime' set but not used [-Wunused-but-set-variable]
     int ztime[108];
         ^
Main.c:18:9: warning: variable 's' set but not used [-Wunused-but-set-variable]
   music s[108];
         ^
*/

Double click to view unformatted code.


Back to problem 100