语言文字宣传标语:第十届青少年信息学奥林匹克普及组阅读程序第四小题

来源:百度文库 编辑:高考问答 时间:2024/05/08 12:37:40
4、 program program4; var c:array[1..2] of string[200]; s:array[1..10] of integer; m,n,i:integer; procedure numara; var cod:boolean; i,j,nr:integer; begin for j:=1 to n do begin nr:=0;cod:=true; for i:=1 to m do if c[i,j]=''''1'''' then begin if not cod then begin cod:=true;inc(s[nr]);nr:=0; end end else begin if cod then begin nr:=1;cod:=false; end else inc(nr); end; if not cod then inc(s[nr]); end; end; begin readln(m,n); for i:=1 to m do readln(c[i]); numara; for i:=1 to m do if s[i] <>0 then write(i,'''' '''',s[i],'''' ''''); end.
输入:3 10
1110000111
1100001111
1000000011输出:_____________________。

1 4 2 1 3 3
简单的模拟一下就出来了