例题7.4今年暑假不AC
#include
#include
using namespace std;
struct program
{
int begin;
int end;
};
bool cmp(program a,program b){
return a.end }
int main()
{
int n;
while(cin>>n)
{
program pro[n];
for(int i=0;i {
cin>>pro[i].begin>>pro[i].end;
}
sort(pro,pro+n,cmp);
int endtime=pro[0].end;
int answer=1;//节目个数
int xb;//要看的节目的下标
int flag=1;//还有没有节目能在今天看了
while(flag==1&&n!=0)
{
for(int i=0;i {
if(pro[i].begin>=endtime)
{
flag=1;
xb=i;break;
}
else
{
flag=0;
}
}
if(flag==1)
{
answer++;
endtime=pro[xb].end;
}
else
break;
}
if(n==0)cout<<"0"< else cout<
}
}
#include
using namespace std;
struct program
{
int begin;
int end;
};
bool cmp(program a,program b){
return a.end
int main()
{
int n;
while(cin>>n)
{
program pro[n];
for(int i=0;i
cin>>pro[i].begin>>pro[i].end;
}
sort(pro,pro+n,cmp);
int endtime=pro[0].end;
int answer=1;//节目个数
int xb;//要看的节目的下标
int flag=1;//还有没有节目能在今天看了
while(flag==1&&n!=0)
{
for(int i=0;i
if(pro[i].begin>=endtime)
{
flag=1;
xb=i;break;
}
else
{
flag=0;
}
}
if(flag==1)
{
answer++;
endtime=pro[xb].end;
}
else
break;
}
if(n==0)cout<<"0"<
}
}
全部评论
相关推荐
02-14 11:30
华南农业大学 Java 点赞 评论 收藏
分享


腾讯
| 实习
| 超多精选岗位
点赞 评论 收藏
分享