VS2010上没有问题,交上去一直Runtime Error(Segment Fault),求指导
cxc402022-10-04 11:39:541条回答
VS2010上没有问题,交上去一直Runtime Error(Segment Fault),求指导
代码:
#include
#include
#include
int main()
{
char s[20],line[205],last[10];
int len,i;
while(1)
{
scanf("%s",s);
fflush(stdin);
if(!strcmp(s,"ENDOFINPUT")) break;
//scanf("%[^n]s",line);
gets(line);
fflush(stdin);
scanf("%s",last);
fflush(stdin);
len=strlen(line);
for(i=0;i='A'&&line[i]='F')
{
line[i]-=5;
}
else
{
line[i]=line[i]-4+'Z'-'A';
}
}
}
printf("%sn",line);
}
return 0;
}
Description
Julius Caesar lived in a time of danger and
intrigue.The hardest situation Caesar ever faced was keeping himself
alive.In order for him to survive,he decided to create one of the
first ciphers.This cipher was so incredibly sound,that no one could
figure it out without knowing how it worked.
You are a sub captain of Caesar's army.It is your job to decipher the
messages sent by Caesar and provide to your general.The code is simple.
For each letter in a plaintext message,you shift it five places to the
right to create the secure message (i.e.,if the letter is 'A',the
cipher text would be 'F').Since you are creating plain text out of
Caesar's messages,you will do the opposite:
Cipher text
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Plain text
V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
Only letters are shifted in this cipher.Any non-alphabetical character
should remain the same,and all alphabetical characters will be upper
case.
Input
Input to this problem will consist of a
(non-empty) series of up to 100 data sets.Each data set will be
formatted according to the following description,and there will be no
blank lines separating data sets.All characters will be uppercase.
A single data set has 3 components:
Start line - A single line,"START"
Cipher message - A single line containing from one to two hundred
characters,inclusive,comprising a single message from Caesar
End line - A single line,"END"
Following the final data set will be a single line,"ENDOFINPUT".
Output
For each data set,there will be exactly one line of output.This is the original message by Caesar.
代码:
#include
#include
#include
int main()
{
char s[20],line[205],last[10];
int len,i;
while(1)
{
scanf("%s",s);
fflush(stdin);
if(!strcmp(s,"ENDOFINPUT")) break;
//scanf("%[^n]s",line);
gets(line);
fflush(stdin);
scanf("%s",last);
fflush(stdin);
len=strlen(line);
for(i=0;i='A'&&line[i]='F')
{
line[i]-=5;
}
else
{
line[i]=line[i]-4+'Z'-'A';
}
}
}
printf("%sn",line);
}
return 0;
}
Description
Julius Caesar lived in a time of danger and
intrigue.The hardest situation Caesar ever faced was keeping himself
alive.In order for him to survive,he decided to create one of the
first ciphers.This cipher was so incredibly sound,that no one could
figure it out without knowing how it worked.
You are a sub captain of Caesar's army.It is your job to decipher the
messages sent by Caesar and provide to your general.The code is simple.
For each letter in a plaintext message,you shift it five places to the
right to create the secure message (i.e.,if the letter is 'A',the
cipher text would be 'F').Since you are creating plain text out of
Caesar's messages,you will do the opposite:
Cipher text
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Plain text
V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
Only letters are shifted in this cipher.Any non-alphabetical character
should remain the same,and all alphabetical characters will be upper
case.
Input
Input to this problem will consist of a
(non-empty) series of up to 100 data sets.Each data set will be
formatted according to the following description,and there will be no
blank lines separating data sets.All characters will be uppercase.
A single data set has 3 components:
Start line - A single line,"START"
Cipher message - A single line containing from one to two hundred
characters,inclusive,comprising a single message from Caesar
End line - A single line,"END"
Following the final data set will be a single line,"ENDOFINPUT".
Output
For each data set,there will be exactly one line of output.This is the original message by Caesar.
已提交,审核后显示!提交回复
共1条回复
- winter6666 共回答了22个问题
|采纳率100% - 数组越界了 你数组开大点试试
orz还有正则表达式 - 1年前
相关推荐
- VS2010中C板块强制类型转换.
VS2010中C板块强制类型转换.
如题。举个简单的例子:
int m,n;
float x,y;
x=2.5;
y=4.7;
m=(int)x+y;
n=(int)x+m/3;
通过单步调试 m的值居然为6,n的值为4.
再看如下,把强制类型后面操作数加():
int m,n;
float x,y;
x=2.5;
y=4.7;
m=(int)(x+y);
n=(int)(x+m/3);
单步调试:m=7,n=4. vs2010是旗舰版。疑问如下:
1 m后面加括号与不加括号值不一样,而n的值没变化。
2 m的值不加括号的情况下为什么是6,而不是先对x强制整型后再与浮点数y相加,得到6.7呢。
岛上的木瓜1年前3 -
京城游客 共回答了26个问题
|采纳率92.3%VS2010默认是Unicode的,在VC 6.0中编译成功的项目在VS2010中常会出现类型如使用CreateDC("DISPLAY",NULL,NULL,NULL)就会报错,如果使用强制转换(L1年前查看全部
- VS2010下配置openCV2.2后写了个关于标定的程序
VS2010下配置openCV2.2后写了个关于标定的程序
在编译后出现如下错误:
1>Cal.obj :error LNK2019:无法解析的外部符号 _cvCalibrateCamera2,该符号在函数 _wmain 中被引用
1>Cal.obj :error LNK2019:无法解析的外部符号 _cvDrawChessboardCorners,该符号在函数 _wmain 中被引用
1>Cal.obj :error LNK2019:无法解析的外部符号 _cvFindChessboardCorners,该符号在函数 _wmain 中被引用
1>C:UserskangDesktopCalDebugCal.exe :fatal error LNK1120:3 个无法解析的外部命令
不知道有没有人知道是哪没有配置好?
opencv_core220d.lib
opencv_highgui220d.lib
opencv_video220d.lib
opencv_ml220d.lib
opencv_legacy220d.lib
opencv_imgproc220d.lib
连接已添加!路径已包含!米玛11年前4 -
SoarBar 共回答了23个问题
|采纳率95.7%我也遇到过这个问题,请问您解决了吗?
我已经解决了,就是少加了几个lib,如:
#pragma comment( lib,"opencv_imgproc243.lib" )
#pragma comment( lib,"opencv_legacy243.lib" )
#pragma comment( lib,"opencv_calib3d243.lib" )
#pragma comment( lib,"opencv_contrib243.lib" )
,加上去就好啦1年前查看全部
- 请问vs2010中,chart控件画曲线图能否将坐标原点置于左上角,即y轴正方向向下?
困惑的ELLA1年前1
-
林枫lf 共回答了16个问题
|采纳率81.3%如果Y轴为负值,那么数据就是向下的;如果为正值,可以处理为负值,也可以直接设置为反向显示:
this.chart1.ChartAreas[0].AxisY.IsReversed = true;1年前查看全部
大家在问
- 1阅读下面漫画《家庭一幕》回答下列问题。 (1)儿子的情绪反映了什么心理,这种心理通常有哪些表现?
- 2小强到商店买同样的文具,如果买练习本3本,圆珠笔7支,文具盒1个共9.45元.如果买这样的练习本
- 3下列各项中,对作品故事情节的叙述不正确的两项是(5分) A.宝玉的一件用孔雀毛线织成的雀金裘被烧了一个洞,但第二天要穿,
- 4关于水的电子式的问题为什么水的电子式O的周围不用加[ ] 而且不用标出电荷的正负?那请问怎样的才是共价化合物,怎样是离子
- 5I am not used ____ ____ to like that
- 6(1)化学用语可准确、简洁地记录、表达和交流化学信息.请用化学符号填写:
- 7若数列{a n }的前n项和S n 是(1+x) n 二项展开式中各项系数的和(n=1,2,3,…).
- 8英语翻译get nasty神魔意思
- 9数学里尖角是什么
- 10用括号中所给动词的正确形式填空.[急用]
- 11五年级英语基本功的几道题,在今天8点之前告诉我
- 12the house belongs to my aunt but she______here any more
- 13选出正确的词语画上横线。1.贝多芬在(寂静、幽静、肃静)的乡村小路上散步。2.贝多芬在音乐创作方面取得了巨大(成就、成绩
- 14在△ABC中,∠A=[π/6],D是BC边上任意一点(D与B、C不重合),且丨AB|2=|AD|2+BD•DC,则∠B=
- 15请问高尚品德是什么意思?