新手求教

本人初中新手(基本什么都不会,本题采用无赖方法)编译错误,请各位指正(Pascal)
var
subwaystart:array[1..100] of integer;

subwaystop:array[1..100] of integer;
subway:array[1..100] of integer;
m,l,tree,i,j,k,o,trway:integer;
begin
read(l,m);
for i:=1 to m do
read(subwaystart[i],subwaystop[i]);
tree:=l+1;
for j:=1 to m do
for k:=1 to m do
begin
if subwaystop[k]>=subwaystart[j]>=subwaystart[k]and k<>j and subwaystop[k]<=subwaystop[j]
then
begin
subwaystop[k]:=subwaystop[j];
subwaystart[j]:=0;
subwaystop[j]:=-1
end;
if subwaystop[k]>=subwaystart[j]>=subwaystart[k]and k<>j and subwaystop[k]>subwaystop[j]
then
begin
subwaystart[j]:=0;
subwaystop[j]:=-1
end;
if subwaystop[k]>=subwaystop[j]>=subwaystart[k]and k<>j and subwaystart[k]>=subwaystop[j]
then
begin
subwaystart[k]:=subwaystart[j];
subwaystart[j]:=0;
subwaystop[j]:=-1
end;
end;
trway:=0;
for o:=1 to m do
trway:=trway+subwaystop[o]-subwaystart[o]+1;
tree:=tree-trway;
write(tree);
end.

3 条评论

  • @ 2016-10-26 12:50:57

    “”#include<iostream>
    using namespace std;
    int a[101],b[101],l[10001];
    int main()
    {
    int lon,m,sum=0;
    cin>>lon>>m;
    for(int i=0;i<=lon;i++) l[i]=1;
    for(int i=0;i<m;i++) cin>>a[i]>>b[i];
    for(int i=0;i<m;i++)
    {
    for(int k=a[i];k<=b[i];k++) l[k]=0;
    }
    for(int i=0;i<=lon;i++)
    {
    if(l[i]==1)
    sum++;
    }
    cout<<sum;
    return 0;
    }”

  • @ 2016-10-26 12:50:34

    #include<iostream>
    using namespace std;
    int a[101],b[101],l[10001];
    int main()
    {
    int lon,m,sum=0;
    cin>>lon>>m;
    for(int i=0;i<=lon;i++) l[i]=1;
    for(int i=0;i<m;i++) cin>>a[i]>>b[i];
    for(int i=0;i<m;i++)
    {
    for(int k=a[i];k<=b[i];k++) l[k]=0;
    }
    for(int i=0;i<=lon;i++)
    {
    if(l[i]==1)
    sum++;
    }
    cout<<sum;
    return 0;
    }

  • @ 2016-09-10 14:43:51

    校门外的树要这么长????♂♂♂♂

  • 1

信息

ID
1103
难度
4
分类
模拟 点击显示
标签
递交数
14290
已通过
6515
通过率
46%
被复制
50
上传者