ZOJ 1243 URLs

        这是一个字符串处理的题目,这类题除了繁一点已经没有什么难度 了,看懂题一切OK,我的代码很繁,ac之后你可以看看网上别人的代码.

 

 

#include<stdio.h> #include<string.h> #include<ctype.h> int main(void) { int i,Ncases,j; char a[70]; while(scanf("%d",&Ncases) != EOF) { getchar(); for( i = 1 ; i <= Ncases ; i++ ) { j = 0; printf("URL #%d/n",i); gets(a); printf("Protocol = "); while(a[j] != ':') { putchar(a[j++]); } printf("/n"); j += 3; printf("Host = "); while(a[j] != ':' && a[j] != '/' && a[j] != '/0') putchar(a[j++]); printf("/n"); if(a[j] == ':') { printf("Port = "); while(isdigit(a[++j])) putchar(a[j]); printf("/n"); printf("Path = "); if(a[j] != '/0') puts(a+j+1); else printf("<default>/n"); } else if(a[j] == '/') { printf("Port = <default>/n"); printf("Path = "); puts(a+j+1); } else { printf("Port = <default>/n"); printf("Path = <default>/n"); } printf("/n"); } } return 0; }

你可能感兴趣的:(url,Path)