55 条题解
- 
  1沉江底 LV 9 @ 2017-05-31 18:48:46 这题两点要注意:句子的结尾不是'\n',好像是另一种换行符。。。 第二点,既然如此不如直接判断读入的单词的最后一个字符是否是标点符号来判断是否结束,这样就避免了第二个点后面还存在空格的情况,至于为什么我后面的单词没读到这种情况,我也不知道啦~就这样,昨天晚上写的两道题都有毒。。。 #include<iostream> #include<cstring> #include<vector> using namespace std; vector<string>sen; char words[100][100]={0}; bool check(int p,int q) { int count=0; for(int i=0;i<sen[p].size();i++) { if(sen[p][i]!=words[q][i]&&count==0) { count++; } else if(sen[p][i]!=words[q][i]&&count!=0) { return false; } } return true; } int main(void) { string sentence,index; int n=0,count=0; char symbol='\0'; cin>>n; while(1) { getchar(); cin>>index; if(index[index.size()-1]=='!') { symbol=index[index.size()-1]; index.erase(index.end()-1); sen.push_back(index); break; } sen.push_back(index); } sen[0][0]+='a'-'A'; for(int i=0;i<n;i++) { cin>>words[i]; } for(int i=0;i<sen.size();i++) { for(int j=0;j<n;j++) { if(sen[i].size()==strlen(words[j])) { if(strcmp(sen[i].c_str(),words[j])==0) { break; } if(check(i,j)) { sen[i]=words[j]; count++; break; } } } } sen[0][0]+='A'-'a'; cout<<count<<endl; for(int i=0;i<sen.size();i++) { if(sen.size()) cout<<sen[i]; int p=sen.size(); if(i!=p-1) { cout<<' '; } else { cout<<symbol; } } //cout<<symbol<<endl; }
- 
  1@ 2008-10-15 11:45:26哪位大侠知道最后一个数据是什么,我觉得自己该考虑的问题都考虑了,比如多余的空格,字母大小写之类的,(第二组没有CHEAT,直接过了 )但最后一组就是过不了……囧谁知道最后一个数据到底是什么啊~~~~ 
- 
  0@ 2021-12-16 19:27:05焯,图片呢??????????????????????????????????????????????????????????? 
- 
  0@ 2009-11-04 16:45:30**后来者注意!! 第二个数据有问题!! 
 句子行末居然有空格!!
 害得我以为自己超时了优化了好几次,提交了好几次!!
 **
- 
  0@ 2009-10-29 12:16:45交了2次..... 
 想了N久N久为啥我的输出比标准输出长,原来是因为刚才边写代码边看漫画的时候把题看漏了....
 要输出错误单词数....
 ---|---|---|---|---|---|---|---|---|---|-
 编译通过...
 ├ 测试数据 01:答案正确... 0ms
 ├ 测试数据 02:答案正确... 0ms
 ├ 测试数据 03:答案正确... 0ms
 ├ 测试数据 04:答案正确... 0ms
 ├ 测试数据 05:答案正确... 0ms
 ---|---|---|---|---|---|---|---|-
 Accepted 有效得分:100 有效耗时:0ms
- 
  0@ 2009-09-12 16:20:09编译通过... 
 ├ 测试数据 01:答案正确... 0ms
 ├ 测试数据 02:答案正确... 0ms
 ├ 测试数据 03:答案正确... 0ms
 ├ 测试数据 04:答案正确... 0ms
 ├ 测试数据 05:答案正确... 0ms
 ---|---|---|---|---|---|---|---|-
 Accepted 有效得分:100 有效耗时:0ms
- 
  0@ 2009-09-06 16:01:08var 
 ch:char; k,n,i,sa:integer;
 s:array[1..500]of string;
 a:array[1..100]of string;
 procedure search(var l:string);
 var i,j,z:integer;
 begin
 for i:=1 to n do
 begin
 z:=0;
 for j:=1 to length(a[i]) do
 if z=2 then break
 else
 if length(l)=length(a[i]) then
 if upcase(l[j])upcase(a[i][j]) then inc(z);
 if(z=1)then begin l:=a[i]; inc(sa); exit; end;
 end;
 end;
 begin
 readln(n); k:=1; sa:=0;
 repeat
 read(ch);
 if ch=' ' then inc(k)
 else if ch'!'then s[k]:=s[k]+ch;
 until ch='!'; readln;
 for i:=1 to n do
 readln(a[i]);
 for i:=1 to k do
 search(s[i]);
 writeln(sa);
 s[1][1]:=upcase(s[1][1]);
 for i:=1 to k do
 if ki then write(s[i],' ')
 else write(s[i],'!');end.题目太水了! 只要在判断单词 是否有差异时 
 加一句 长度是否相等
 就AC了
- 
  0@ 2009-08-26 10:46:02这么水的题怎么通过率这么低? 
- 
  0@ 2009-07-19 20:48:18编译通过... 
 ├ 测试数据 01:答案正确... 0ms
 ├ 测试数据 02:答案正确... 0ms
 ├ 测试数据 03:答案正确... 0ms
 ├ 测试数据 04:答案正确... 0ms
 ├ 测试数据 05:答案正确... 0ms
 ---|---|---|---|---|---|---|---|-
 Accepted 有效得分:100 有效耗时:0ms猥琐的读入!!! 
- 
  0@ 2009-07-14 17:12:04#include 
 #include
 void main()
 {
 int n,i=1,j=0,e=0,f=0,k=0,w;
 char a[100][40],b[100],c;
 scanf("%d",&n);
 getchar();
 gets(b);
 for(i=1;i
- 
  0@ 2009-07-14 10:48:03无语,第五组数据中,求错误的个数,不能从反面考虑,也就是说有哦字典的有些单词可以没有在正文中出现而不是错误的!!脑残!! 
- 
  0@ 2009-07-11 10:27:38一次AC... 感觉不WS 
- 
  0@ 2009-03-10 19:02:16草! 
 猥琐的题!
 句子后面还有空格阿!
 各位小心啊!
- 
  0@ 2009-02-22 20:24:17注意第一个单词开头大写,注意剔除多余空格。 
 就这些问题害我传了n遍啊……
- 
  0@ 2009-02-02 16:51:481.句末有空格。 貌似第二个点没有,自己判断一下就好了。 
 2.字典的单词末尾没有空格。 被骗了好多回。
 3.句首字母要大写
 4.符号肯定就是那个格式,不会出现没有标点符号或者多个空格的情况。此题是降AC率的经典水题。 
- 
  0@ 2008-12-27 14:53:29var n,k:integer; 
 dic:array[1..100] of string;
 dicl:array[1..100] of integer;
 st:array[1..255] of char;
 i,j,l,a,b,c,p,xx,yy:integer;
 ch1,ch2:char;
 flg:boolean;
 function fac(ch1,ch2:char):boolean;
 begin
 if ch1 = ch2 then begin fac:=false ; exit end;
 if ord(ch1) + 22 = ord(ch2) then begin fac:=false ; exit end;
 if ord(ch1) = ord(ch2) + 22 then begin fac:=false ; exit end;
 fac:=true;
 end;
 procedure input;
 begin
 readln(n);
 xx:=1;
 read(st[xx]);
 flg:=true;
 if st[xx] in ['A'..'Z','a'..'z'] then
 begin
 if st[xx] in ['A'..'Z'] then
 st[xx]:=chr(ord(st[xx]) + 32 );
 flg:=false;
 yy:=xx;
 end;
 while st[xx] '!' do
 begin
 inc(xx);
 read(st[xx]);
 if ( st[xx] in ['A'..'Z'] ) and flg then
 begin
 st[xx]:=chr(ord(st[xx]) + 32 );
 flg:=false;
 yy:=xx;
 end;
 end;
 readln;
 for i:= 1 to n do
 begin
 readln(dic[i]);
 dicl[i]:=length(dic[i]);
 end;
 i:=1;
 j:=1;
 k:=0;
 end;
 begin
 input;
 repeat
 while ( not ( st[j] in [' ','!'] ) ) do inc(j);
 l:=j-i;
 for a:= 1 to n do
 begin
 if dicl[a] = l then
 begin
 c:=0;
 for b:= 1 to l do
 begin
 ch1:=dic[a];
 ch2:=st;
 if fac(ch1,ch2) then begin inc(c); p:= b ; end; end;
 if c = 1 then
 begin
 inc(k);
 st:=dic[a][p];
 end;
 end;
 end;
 if st[j] = ' ' then
 begin
 i:= j + 1;
 j:= i ;
 end;
 until st[j] = '!';
 writeln(k);
 st[yy]:= chr(ord(st[yy]) - 32);
 for i:= 1 to xx do write(st[i]);
 writeln;
 end.我对这题很无语....... 
 第1组和第5组怎么了?
- 
  0@ 2008-12-20 14:14:31好水…… 
- 
  0@ 2008-11-19 13:05:02好水的题,本人1次AC……………… 
- 
  0@ 2008-11-09 13:37:07有没有人知道第二个数据。。。。。。。。。。 
- 
  0@ 2008-11-07 15:10:54谁能提供最后一组数据…… 前空格考虑了,中空格考虑了,后空格考虑了,字典后的空格也考虑了…… 连 I love you !这样的空格也考虑了…… 到底错在哪儿? program p1419; 
 var
 a,s:array[1..100] of string;
 i,j,k,n,m,r,t:integer;
 c:char;
 procedure ready;
 begin
 readln(n);
 m:=0;
 read(c);
 while c=' ' do read(c);
 while c'!' do
 begin
 inc(m);
 while (c' ') and (c'!') do
 begin
 s[m]:=s[m]+c;
 read(c);
 end;
 while c=' ' do read(c);
 end;
 while s[m]='' do dec(m);
 readln;
 s[1,1]:=chr(ord(s[1,1])+ord('a')-ord('A'));
 for i:=1 to n do
 begin
 readln(a[i]);
 j:=length(a[i]);
 while a=' ' do
 begin
 delete(a[i],j,1);
 dec(j);
 end;
 end;
 end;
 procedure work;
 var
 x:integer;
 begin
 for i:=1 to n do
 begin
 for j:=1 to m do
 if length(s[j])=length(a[i]) then
 begin
 x:=0;
 k:=1;
 while (x