View Code of Problem 9

#include<stdio.h> 
#include<string.h>
int main(){ 
    int i,j,k,flag,n,sum;
    char a[20];
    while(scanf("%d",&n)!=EOF){
    	sum=0;
    	flag=0;
    	for(i=0;i<n;i++){
    		scanf("%s",a);
		    if(a[0]=='P'&&a[1]=='l')
		    	sum+=5;
			else if(a[0]=='P'&&a[1]=='r')
		        sum+=8;
		    else if(a[0]=='A'){
		    	sum+=10;
		    	flag=1;
			}
		        
		    else if(a[0]=='L')
		        sum+=15;
		    else if(a[0]=='S')
		        sum+=20;
		    scanf("%s",a);
		}
		if(n>=10&&s>0) sum+=50;
    	printf("Case #%d: %d\n",++k,sum);
			
		
	}
	return 0;
} 


/*
Main.c: In function 'main':
Main.c:26:13: error: 's' undeclared (first use in this function)
   if(n>=10&&s>0) sum+=50;
             ^
Main.c:26:13: note: each undeclared identifier is reported only once for each function it appears in
Main.c:4:15: warning: variable 'flag' set but not used [-Wunused-but-set-variable]
     int i,j,k,flag,n,sum;
               ^
Main.c:4:11: warning: unused variable 'j' [-Wunused-variable]
     int i,j,k,flag,n,sum;
           ^
*/

Double click to view unformatted code.


Back to problem 9