题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3125
4 http://acm.whu.edu.cn/felioj http:/\acm.whu.edu.cn/11111011001/ \home\whuacm\Slash\yama Z:\movie/chaeyeon
It‘s a URL! http://acm.whu.edu.cn/felioj It‘s a URL! http://acm.whu.edu.cn/11111011001/ It‘s a path in Unix-like systems! /home/whuacm/Slash/yama It‘s a path in Windows system! Z:\movie\chaeyeon
代码如下:
//#pragma warning (disable:4786)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <climits>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <deque>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
const double eps = 1e-9;
//const double pi = atan(1.0)*4;
const double pi = 3.1415926535897932384626;
#define INF 1e18
//typedef long long LL;
//typedef __int64 LL;
bool Judge(char c)
{
if(c == '/' || c == '\\')
return true;
return false;
}
int main()
{
int t;
char str[57];
scanf("%d",&t);
while(t--)
{
memset(str,'\0',sizeof(str));
scanf("%s",str);
int len = strlen(str);
if(Judge(str[0]))
{
printf("It's a path in Unix-like systems!\n");
for(int j = 0; j < len; j++)
{
if(str[j] == '\\')
printf("/");
else
printf("%c",str[j]);
}
printf("\n");
continue;
}
for(int i = 0; i < len; i++)
{
if(Judge(str[i]) && Judge(str[i+1]))
{
printf("It's a URL!\n");
for(int j = 0; j < len; j++)
{
if(str[j] == '\\')
printf("/");
else
printf("%c",str[j]);
}
printf("\n");
break;
}
else if(Judge(str[i]))
{
printf("It's a path in Windows system!\n");
for(int j = 0; j < len; j++)
{
if(str[j] == '/')
printf("\\");
else
printf("%c",str[j]);
}
printf("\n");
break;
}
}
}
return 0;
}
hdu 3125 Slash(模拟),布布扣,bubuko.com
原文:http://blog.csdn.net/u012860063/article/details/38615885