杭电 2000


#include <iostream>
using namespace std;
#define MAXN 4
int main()
{
//char arr[MAXN] = {0};
char arr[MAXN];
memset(arr,0,MAXN);
while (cin >> arr)
{
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2-i; j++)
{
char temp;
if (arr[j] > arr[j+1])
{
temp = arr[j+1];
arr[j+1] = arr[j];
arr[j] = temp;
}
}
}
// for (int i = 0; i < 3; i++)
// {
// cout << arr[i] << ‘ ‘;
// }
// cout << endl;
//
cout << arr[0] <<‘ ‘ << arr[1] <<‘ ‘ << arr[2]<<endl;
}
return 0;
}

心得: 数组定义要够大,防止溢出。

杭电 2000,布布扣,bubuko.com

时间: 2024-10-11 20:03:46

杭电 2000的相关文章

杭电2000 ASCII码排序

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2000 注意过滤掉输入三个字符之后的回车键即可 #include<stdio.h> int main() { char a,b,c,t; while(scanf("%c%c%c",&a,&b,&c)!=EOF) { getchar(); if(a>b) { t=a; a=b; b=t; } if(a>c) { t=a; a=c; c=t; }

杭电 HDU 1164 Eddy&#39;s research I

Eddy's research I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7117    Accepted Submission(s): 4268 Problem Description Eddy's interest is very extensive, recently  he is interested in prime

hdu 1016 Prime Ring Problem DFS解法 纪念我在杭电的第一百题

Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 29577    Accepted Submission(s): 13188 Problem Description A ring is compose of n circles as shown in diagram. Put natural num

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

杭电1162--Eddy&#39;s picture(Prim()算法)

Eddy's picture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8070    Accepted Submission(s): 4084 Problem Description Eddy begins to like painting pictures recently ,he is sure of himself to b

杭电1276--士兵队列训练问题

士兵队列训练问题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4605    Accepted Submission(s): 2148 Problem Description 某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行

杭电 HDU 1038 Biker&#39;s Trip Odometer

Biker's Trip Odometer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4745    Accepted Submission(s): 3144 Problem Description Most bicycle speedometers work by using a Hall Effect sensor faste

杭电 1248 寒冰王座(完全背包)

http://acm.hdu.edu.cn/showproblem.php?pid=1248 寒冰王座 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10792    Accepted Submission(s): 5476 Problem Description 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票

杭电 1231 最大连续子序列

http://acm.hdu.edu.cn/showproblem.php?pid=1231 最大连续子序列 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 18622    Accepted Submission(s): 8273 Problem Description 给定K个整数的序列{ N1, N2, ..., NK },其任意