为什么自己编译器没问题,ACM老是runtime error求救!

miaomiao3777 2011-12-27 09:26:59
3828. Stick
Total: 39 Accepted: 23 Rating:
Unrated


Time Limit: 1sec Memory Limit:32MB
Description
Anthony has collected a large amount of sticks for manufacturing chopsticks. In order to simplify his job, he wants to fetch two equal-length sticks for machining at a time. After checking it over, Anthony finds that it is always possible that only one stick is left at last, because of the odd number of sticks and some other unknown reasons. For example, Anthony may have three sticks with length 1, 2, and 1 respectively. He fetches the first and the third for machining, and leaves the second one at last. You task is to report the length of the last stick.
Input
The input file will consist of several cases.
Each case will be presented by an integer n (1<=n<=100, and n is odd) at first. Following that, n positive integers will be given, one in a line. These numbers indicate the length of the sticks collected by Anthony.
The input is ended by n=0.
Output
For each case, output an integer in a line, which is the length of the last stick.
Sample Input
Copy sample input to clipboard
3
1
2
1
0
Sample Output
2
// Problem#: 3828
// Submission#: 1138408
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include<iostream>
//#define N 100;
using namespace std;

int main()
{
int n;
while(cin>>n && n!=0)
{
int v[10]={0};

for(int i=0; i<n; i++)
{
int num;
cin>>num;

v[num]++;
if(v[num]==2)
v[num]=0;

}
int j=0;
while(j<=10)
{
if(v[j]==1)
cout<<j<<endl;

j++;
}
}
// system("PAUSE");
return 0;
}

...全文
41 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

64,649

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧