A 1005 Spell It Right (20 point(s))

  25分的题目,比较简单,注意N的范围,用字符串处理即可。

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring> using namespace std; int main()
{
const char * numStr[]={"zero","one","two","three","four","five","six","seven","eight","nine"};
string tmpStr;
cin >> tmpStr;
int sum = ;
for(int i = ; i < tmpStr.size(); ++ i)
sum += tmpStr[i]-'';
char charArray[];
sprintf(charArray, "%d", sum);
for(int i = ; i < strlen(charArray); ++ i)
{
if(i > ) printf(" ");
printf("%s", numStr[charArray[i]-'']);
}
return ;
}

A 1006 1006 Sign In and Sign Out (25 point(s))

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring> using namespace std; int main()
{
int M, tmpHour, tmpMinute, tmpSecond, unLockTime=*, lockTime=-;
cin >> M;
string tmpStr, unLockId, lockId;
for(int i = ; i < M; ++i)
{
cin >> tmpStr;
scanf("%d:%d:%d", &tmpHour, &tmpMinute, &tmpSecond);
tmpHour = tmpHour*+tmpMinute*+tmpSecond;
if(tmpHour < unLockTime)
{
unLockId = tmpStr;
unLockTime = tmpHour;
}
scanf("%d:%d:%d", &tmpHour, &tmpMinute, &tmpSecond);
tmpHour = tmpHour*+tmpMinute*+tmpSecond;
if(tmpHour > lockTime)
{
lockId = tmpStr;
lockTime = tmpHour;
}
}
cout << unLockId << " " << lockId;
return ;
}

A 1007 Maximum Subsequence Sum (25 point(s))

  经典的最大子序列和问题,注意 全为负数只有负数和0 这两种情况即可,理不清题意可能会有一两个点过不去。

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring> using namespace std; int main()
{
int K, tmpSt, resSt, resEnd, tmpNum, sum = -, maxSum = -;
cin >> K;
bool negFlag = true;
for(int i = ; i < K; ++ i)
{
cin >> tmpNum;
if(i==)
resSt = tmpNum;
if(tmpNum >= )
negFlag = false;
if(sum < )
{
sum = ;
tmpSt = tmpNum;
}
sum += tmpNum;
if(sum > maxSum)
{
maxSum = sum;
resSt = tmpSt;
resEnd = tmpNum;
}
}
if(negFlag)
cout << << " " << resSt << " " << tmpNum;
else
cout << maxSum << " " << resSt << " " << resEnd;
return ;
}

A 1008 Elevator (20 point(s))

  一个直观的数学计算问题

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring> using namespace std; int main()
{
int N, tmpNum, tmpFloor = , sum = ;
cin >> N;
for(int i = ; i < N; ++ i)
{
cin >> tmpNum;
if(tmpFloor < tmpNum)
sum += + *(tmpNum - tmpFloor);
else
sum += + *(tmpFloor - tmpNum);
tmpFloor = tmpNum;
}
cout << sum;
return ;
}

PAT A1005-1008的更多相关文章

  1. PAT 乙级 1008

    题目 题目地址:PAT 乙级 1008 思路 本题需要注意的一点是当 m > n 的时候会出现逻辑性的错误,需要在 m > n 情况下对m做模运算,即 m % n 代码 #include ...

  2. PAT乙级 1008. 数组元素循环右移问题 (20)

    1008. 数组元素循环右移问题 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 一个数组A中存有N(N>0)个整数,在不允 ...

  3. [C++]PAT乙级1008.数组元素循环右移问题 (20/20)

    /* 1008. 数组元素循环右移问题 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 一个数组A中存有N(N>0)个整数, ...

  4. PAT Basic 1008

    1008 数组元素循环右移问题 (20 分) 一个数组A中存有N(>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(≥0)个位置,即将A中的数据由(A​0​​A​1​​⋯A​N ...

  5. PAT 乙级 1008 数组元素循环右移问题 (20) C++版

    1008. 数组元素循环右移问题 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 一个数组A中存有N(N>0)个整数,在不允 ...

  6. PAT 甲级 1008 Elevator (20)(代码)

    1008 Elevator (20)(20 分) The highest building in our city has only one elevator. A request list is m ...

  7. PAT甲 1008. Elevator (20) 2016-09-09 23:00 22人阅读 评论(0) 收藏

    1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...

  8. PAT乙级1008

    1008 数组元素循环右移问题 (20 分)   一个数组A中存有N(>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(≥0)个位置,即将A中的数据由(A​0​​A​1​​⋯A ...

  9. PAT 甲级 1008 Elevator (20)(20 分)模拟水题

    题目翻译: 1008.电梯 在我们的城市里,最高的建筑物里只有一部电梯.有一份由N个正数组成的请求列表.这些数表示电梯将会以规定的顺序在哪些楼层停下.电梯升高一层需要6秒,下降一层需要4秒.每次停下电 ...

  10. 【PAT】1008. 数组元素循环右移问题 (20)

    1008. 数组元素循环右移问题 (20) 一个数组A中存有N(N>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(M>=0)个位置,即将A中的数据由(A0A1……AN- ...

随机推荐

  1. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-signal

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...

  2. HDU - 6000 Wash(优先队列+贪心)

    题意:已知有L件衣服,M个洗衣机,N个烘干机,已知每个机器的工作时间,且每个机器只能同时处理一件衣服,问洗烘完所有衣服所需的最短时间. 分析: 1.优先队列处理出每件衣服最早的洗完时间. 2.优先队列 ...

  3. 《Python爬虫技术:深入理解原理、技术与开发》已经出版,送Python基础视频课程

    好消息,<Python爬虫技术:深入理解原理.技术与开发>已经出版!!!   JetBrains官方推荐图书!JetBrains官大中华区市场部经理赵磊作序!送Python基础视频课程!J ...

  4. Power BI Premium

    Power BI Premium的设计是为了满足拥有大量数据的大公司的需求.微软已经重新构建了Power BI的架构,以允许大量的“只读”用户.Premium用户还可以利用很多新功能. Power B ...

  5. 这篇干货让你在零点前完成学术Essay写作

    写论文,做研究,上课,参加课外活动,与他人social...在美国,你会有很多的事情需要你去做,如何将自己的时间平衡的分配到自己的学习生活以及私人生活中,就显得尤为重要,而这些问题也是影响中国学生的重 ...

  6. RMAN > BACKUP VALIDATE DATABASE ARCHIVELOG ALL

    使用BACKUP ... VALIDATE 命令: You can use the BACKUP VALIDATE command to do the following:        (1)Che ...

  7. 10 Json(unity3D)

    //写入json文档注意事项: 1.在Asset下要有一个StreamingAssets文件夹 2.在文件夹内,有一个已创建好的json空文档 3.引入命名空间 using Litjson; usin ...

  8. 吴裕雄--天生自然 JAVASCRIPT开发学习:作用域

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  9. Flink:动态表上的连续查询

    用SQL分析数据流 越来越多的公司在采用流处理技术,并将现有的批处理应用程序迁移到流处理或者为新的应用设计流处理方案.其中许多应用程序专注于分析流数据.分析的数据流来源广泛,如数据库交易,点击,传感器 ...

  10. Android进阶——多线程系列之wait、notify、sleep、join、yield、synchronized关键字、ReentrantLock锁

    多线程一直是初学者最困惑的地方,每次看到一篇文章,觉得很有难度,就马上叉掉,不看了,我以前也是这样过来的.后来,我发现这样的态度不行,知难而退,永远进步不了.于是,我狠下心来看完别人的博客,尽管很难但 ...