读入字符串的两种不同方式导致两个截然不同的提交结果。。
http://ac.jobdu.com/problem.php?id=1190
下面这个代码提交结果是是Accepted
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct BigNum
{
int len;
char str[1010];
}bigNum[110];
int cmp(const BigNum& a,const BigNum& b)
{
if(a.len!=b.len)
return a.len<b.len;
else
return strcmp(a.str,b.str)<0;
}
int main(void)
{
int i,n;
while(scanf("%d",&n)!=EOF)
{
//getchar();
for(i=0;i<n;i++)
{
//gets(bigNum[i].str);
scanf("%s",bigNum[i].str);
bigNum[i].len=strlen(bigNum[i].str);
}
sort(bigNum,bigNum+n,cmp);
for(i=0;i<n;i++)
puts(bigNum[i].str);
}
return 0;
}
下面这个代码提交结果是是Runtime Error
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct BigNum
{
int len;
char str[1010];
}bigNum[110];
int cmp(const BigNum& a,const BigNum& b)
{
if(a.len!=b.len)
return a.len<b.len;
else
return strcmp(a.str,b.str)<0;
}
int main(void)
{
int i,n;
while(scanf("%d",&n)!=EOF)
{
getchar();
for(i=0;i<n;i++)
{
gets(bigNum[i].str);
//scanf("%s",bigNum[i].str);
bigNum[i].len=strlen(bigNum[i].str);
}
sort(bigNum,bigNum+n,cmp);
for(i=0;i<n;i++)
puts(bigNum[i].str);
}
return 0;
}
至今还是不明白这是为什么,哎。。。
分享到:
相关推荐
我装的是QTP10,之前还用的好好的,今天不知道怎么回事,我把QTP关了后再启动就看见 QTP10 R6025 Runtime Error,我上网查了相关文章也没能解决,看论坛上也有人遇到过,但是没有答案,各位XDJM,帮忙看看哈。...
runtime error R6002 -floating point support not loaded 将未出现过该错误的电脑中Keil的\ARM\ARMCC\bin\armlink.exe复制,覆盖掉报错电脑中的Keil安装目录下\ARM\ARMCC\bin\armlink.exe即可。每天出现该报错,...
解决docker报错Error response from daemon oci runtime error
Runtime Error! Program: C:\Program Fies\Mindjet\MindManager 11\MindManager.exe R6025 - pure virtual function call 记得以前装2012版时,也有这样的问题, 后来是在网上找了模板替换,但这是最新版,在...
Microsoft Visual C++ Runtime Library Runtime Error! Program: D:\Program Files\HP\QuickTest Professional\bin\QTPro.exe R6025 -pure virtual function call 成功解决QTP10的以上问题!
电脑出现runtime error错误提示的解决办法.docx
在网上看到好多人遇到错误Runtime_Error_R6034,好不容易找到答案,不敢独享
弹出“Runtime Error!”出现iexplorer.exeR6025.docx
下载options_win32.zip,用options_win32\bin\win32\mbuildopts下的三个bat文件,覆盖C:\Program Files\MATLAB\R2009a\bin\win32\...mbuild -setup命令 解决vs2008调用matlab的dll文件 报runtime error R6034的问题!
小米手机助手runtime error怎么解决.docx
Runtime Error! Program:c:\windows\exploorer.exe This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
Delphi 的 runtime错误代码列表
vs2008 运行库(包括x86 x64 Debug和Release版) vs90(vs2008) sp1 32 64位运行库,包括Debug和Release版程序,都可以运行,vs2008编译的程序或者vs2008sp1编译的程序都可以运行。
文章目录Tensorflow 2.1 报错整合RuntimeError: `loss` passed to Optimizer.compute_gradients should be a function when eager execution is enabled.RuntimeError: Attempting to capture an EagerTensor ...
VB6 Type Mismatch error
m_pConnection->Execute runtime errorm_pConnection->Execute runtime error
Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely ...
标题用pycharm导入numpy包的和使用时报错:RuntimeError: The current Numpy installation (‘D:\python3.6\lib\site-packages\numpy\init.py 1.file→settings→project interpreter→+(建议用pychon3.6版本,我...
MindManager无法保存 提示参数不正确 打开时老出现Runtime Error 可用该程序修复, 补充:挺好用的,我试过了
运行时错误.net 这个 gem 充当的代理。 为代理安装 gem 以处理应用...为防止在开发时发出错误,请确保RUNTIMEERROR_EMAIL设置环境变量RUNTIMEERROR_EMAIL 。 执照 :copyright: RuntimeError.net 2013。查看许可证了