problem link:
Discuss: this a simply implementation problem. in this problem you can use a bool array then just use memset function and changed the value for every return number keep it mind that you should take n+1 th bool array size. and there is no tricky part in this problem
try yourself before see the code
#include<bits/stdc++.h>
using namespace std;
int main()
{
// freopen("input.txt","r",stdin);
// freopen("out.txt","w",stdout);
int n,i,j,cnt=0,flag,r;
while(cin >>n>>r)
{
bool chekc[100000];
flag=0;
memset(chekc,0,n+1);
for(i=0;i<r;i++)
{
cin >>j;
chekc[j]=1;
}
for(i=1;i<=n;i++)
{
if(!chekc[i])
{
cout <<i<<' ';
flag=1;
}
}
if(!flag)
cout <<'*';
cout <<endl;
}
return 0;
}
Discuss: this a simply implementation problem. in this problem you can use a bool array then just use memset function and changed the value for every return number keep it mind that you should take n+1 th bool array size. and there is no tricky part in this problem
try yourself before see the code
#include<bits/stdc++.h>
using namespace std;
int main()
{
// freopen("input.txt","r",stdin);
// freopen("out.txt","w",stdout);
int n,i,j,cnt=0,flag,r;
while(cin >>n>>r)
{
bool chekc[100000];
flag=0;
memset(chekc,0,n+1);
for(i=0;i<r;i++)
{
cin >>j;
chekc[j]=1;
}
for(i=1;i<=n;i++)
{
if(!chekc[i])
{
cout <<i<<' ';
flag=1;
}
}
if(!flag)
cout <<'*';
cout <<endl;
}
return 0;
}
No comments:
Post a Comment