您的位置:首页 > 大数据 > 人工智能

HDU(简单题目) 1038 Biker's Trip Odometer 1039 Easier Done Than Said?

2016-06-16 22:36 591 查看
心情不好,找了几个水题

1038 Biker's Trip Odometer

题意难懂,直径 圈数 时间,算总的路程,然而车走的是步数,要化成mile

/*
HDU 1038
题意:直径  圈数  时间
思路:算出总路程,然而这个路程是步数,要换算成mile
*/
#include<iostream>
#include<cstdio>
using namespace std;

const double p = 3.1415927;
int main()
{
double a,b,t,dis,speed;
int time=0;
while(~scanf("%lf%lf%lf",&a,&b,&t)&&b)
{
dis=a*b*p;
dis/=12*5280;
speed=dis*3600/t;
printf("Trip #%d: %.2lf %.2lf\n",++time,dis,speed);
}
return 0;
}


1039 Easier Done Than Said?

题意:略

思路:略

竟然卡了,题意是连续的几个数是怎么样的,而不是连续的几个数是连续的原音,失误,,

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
//char s[5]={'a','e','i','o','u'};
bool vowel(char c)//判断是否为原音
{
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
return true;
return false;
}
int main()
{
char str[25];
while(~scanf("%s",str)&&strcmp("end",str)!=0)
{
int len=strlen(str);
bool flag_vowel=false;//判断是否含有原音
bool consecutive_vowel=true;//判断是否含有连续三个原音或辅音
bool repeat_vowel=true;//判断是否含有连续三个字母
for(int i=0;i<len;i++)
{
if(vowel(str[i]))
{
flag_vowel=true;
break;
}
}
for(int i=0;i<len-2;i++)//不连续
{
if((vowel(str[i])&&vowel(str[i+1])&&vowel(str[i+2]))
||(!vowel(str[i])&&!vowel(str[i+1])&&!vowel(str[i+2])))
consecutive_vowel=false;
}
for(int i=0;i<len-1;i++)
{
if(str[i]==str[i+1])
{
repeat_vowel=false;
if(str[i]=='e'||str[i]=='o')//特殊情况
{
repeat_vowel=true;
}
}
}
if(flag_vowel&&consecutive_vowel&&repeat_vowel)
printf("<%s> is acceptable.\n",str);
else
printf("<%s> is not acceptable.\n",str);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: