View Code of Problem 97

#include <stdio.h>
#include <string.h>
int isp(char str[]){	//判断是否为.exe文件 
	int len=strlen(str),j=0,i;
	char strs[4]  =".exe";
	for(i=len-4;i<=len-1;i++){
		if(str[i]!=strs[j]) return 0;
		j++;
	}
	return 1;
}
int ispp(char a[],char b[]){	//判断是否有相同文件名 
	int len1=strlen(a),len2=strlen(b);
	if(len1-len2!=4) return 0;
	int i,j,k=0;char c[len1];
	for(i=0;i<len1-4;i++)
		c[k++]=a[i];
	c[k]='\0';
	if(strcmp(c,b)==0) return 1;
	else return 0;
}
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		char str[n][100];
		int i,j;
		for(i=0;i<n;i++)
			scanf("%s",&str[i]);
		for(i=0;i<n;i++)
			if(isp(str[i])) 
				for(j=0;j<n;j++) 
					if(ispp(str[i],str[j])) 
						printf("%s\n",str[i]);							
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 97