- 浏览: 36744 次
- 性别:
- 来自: 杭州
最新评论
文章列表
十进制转任意进制,并比较是否是回文数
Sample Input 1:
27 2
Sample Output 1:
Yes
1 1 0 1 1
Sample Input 2:
121 5
Sample Output 2:
No
4 4 1
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
long long n, radix;
int a[1000];
cin> ...
PAT1037 Magic Coupon
- 博客分类:
- PAT
Sample Input:
4
1 2 4 -1
4
7 6 -2 -3
Sample Output:
43
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main()
{
int total = 0;
int NC,NP;
ve ...
由一道面试题改的 把数组排成最小的数
不同之处是这个是直接按字符串处理的
Sample Input:
5 32 321 3214 0229 87
Sample Output:
22932132143287
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
bool compare(const string& str1, cons ...
Sample Input 1:
67 3
Sample Output 1:
484
2
Sample Input 2:
69 3
Sample Output 2:
1353
3
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
using namespace std;
string myadd(string s1,string s2)
{
int del ...
十进制转任意进制
假设十进制数为number,转换的进制为digits,则将numbers%digits(根据余数的情况做相应处理)
结果保存在字符串str中,将numbers变为numbers/digits;直到numbers为零。
得到的结果为逆序,需要将其倒转,倒转后即为所求。
这里不需要倒序,直接转
Sample Input:
73 10
23 2
23 10
-2
Sample Output:
Yes
Yes
No
#include <iostream>
#inclu ...
PAT1012 The Best Rank
- 博客分类:
- PAT
四门功课,输出排名最高的是哪个
Sample Input
5 6
310101 98 85 88
310102 70 95 88
310103 82 87 94
310104 91 91 91
310105 85 90 90
310101
310102
310103
310104
310105
999999
Sample Output
1 C
1 M
1 E
1 A
3 A
N/A
代码比较冗余。
#include <iostream>
#include <string> ...
PAT1011 World Cup Betting
- 博客分类:
- PAT
Sample Input
1.1 2.5 1.7
1.2 3.0 1.6
4.1 1.2 1.1
Sample Output
T T W 37.98
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
int N = 3;
float total = 1;
string str;
while (N--)
{
float x,y,z;
cin>> ...
多项式乘法
Sample Input
2 1 2.4 0 3.2
2 2 1.5 1 0.5
Sample Output
3 3 3.6 2 6.0 1 1.6
#include <string.h>
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int K1,K2;
int count = 0;
float V1[1001] = {0};
float V2[1001] = ...
PAT1008 Elevator
- 博客分类:
- PAT
电梯上升一层6秒,下降一层4秒,每层停留5秒Sample Input: 3 2 3 1 Sample Output: 41
#include <iostream>
using namespace std;
int main()
{
int N;
cin>>N;
int current = 0;
int total = 0;
while (N--)
{
int a;
cin>>a;
if (a & ...
求最大连续子串和
Sample Input:
10
-10 1 2 3 4 -5 -23 3 7 -21
Sample Output:
10 1 4
#include <iostream>
#include <vector>
#include <string>
using namespace std;
void MaSubSum(const vector<int>& a)
{
int first = 0;
int last = 0;
long ma ...
请根据记录找出当天开门和关门的人。
Sample Input:
3
CS301111 15:30:28 17:00:10
SC3021234 08:00:00 11:25:25
CS301133 21:45:00 21:58:40
Sample Output:
SC3021234 CS301133
#include <iostream>
#include <string>
using namespace std;
int main()
{
int M;
cin>>M;
...
计算各个数字的和,并用英文将字母一个一个输出。 Sample Input: 12345 Sample Output: one five
#include <iostream>
#include <string>
using namespace std;
char* fun(int x)
{
switch(x)
{
case 0:
return "zero";
case 1:
return "one";
case 2:
return "two& ...
PAT1004 Counting Leaves
- 博客分类:
- PAT
统计树的每一层上叶子节点的个数 Sample Input 2 1 01 1 02 Sample Output 0 1
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <vector>
using namespace std;
void fun(vector<string> &v, map<string,vector<string&g
多项式加法
Sample Input 2 1 2.4 0 3.2 2 2 1.5 1 0.5 Sample Output 3 2 1.5 1 2.9 0 3.2
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
int main()
{
int count = 0;
vector<double> V(1001,0);
int N;
for (int i = 0; i &l ...
在实际应用中,遇到DrawText绘制2&时,文字乱码。
认真参阅DrawText用法,发现DT_NOPREFIX绘制项。
DT_NOPREFIX
关闭前缀字符的处理。 通常DrawText解释助记前缀字符,&为给其后的字符加下划线,解释&&为显示单个&。指定DT_NOPREFIX,这种处理被关闭。