You are on page 1of 4

v1

1. d)
2.
a) 854
d)
#include <iostream>

using namespace std;

int main()
{
int n,z=0,p=1,c;
cin>>n;
while(n>0)
{
c=n%10;
n/=10;
if(c%3)
{
z=z+p*(9-c);
p*=10;
}
}
cout<<z;
}

v2
1.d)
2.
a) 2 2 1 1 7 7 5
b) 19 18 17 7 0
c)
#include <iostream>

using namespace std;

int main()
{
int x,y;
cin>>x;
if(x>0)
do
{
cin>>y;
if(x>y)
cout<<x%10;
else
cout<<y%10;
x=y;
}while(x>0);
}

d)
#include <iostream>
using namespace std;

int main()
{
int x,y;
cin>>x;
while(x>0)
{
cin>>y;
if(x>y)
cout<<x%10;
else
cout<<y%10;
x=y;
}
}

v3
1. b)
2.
a) 5 9 9 3 5 0

c)
#include <iostream>

using namespace std;

int main()
{
int x,y,z;
cin>>z>>x;
if(x>0)
do
{
cin>>y;
if(z<y-x)
cout<<x%10;
else
cout<<y%10;
x=y;
}while(x>0);
return 0;
}

d)
#include <iostream>

using namespace std;

int main()
{
int x,y,z;
cin>>z>>x;
while(x>0)
{
cin>>y;
if(z<y-x)
cout<<x%10;
else
cout<<y%10;
x=y;
}
}

v4
1. 9
2.
a) 16 14 12 10 8 6
b) 1 -11/ -11 1/ 0 -10/ -10 0
c)
#include <iostream>

using namespace std;

int main()
{
int a,b;
cin>>a>>b;
if(a<b)
{
int s=a;
a=b;
b=s;
}
int x=a;
while(x>=b)
{
if(x%2==0)
cout<<x<<' ';
x--;
}
}

d)
#include <iostream>

using namespace std;

int main()
{
int a,b;
cin>>a>>b;
if(a<b)
{
int s=a;
a=b;
b=s;
}
for(int x=a;x>=b;x--)
if(x%2==0)
cout<<x<<' ';
}

v5
1.b)
2.
a) 1
d)
#include <iostream>

using namespace std;

int main()
{
int x,y=0,z;
cin>>x>>z;
do
{
y=y*10+x%10;
x/=100;
}while(x);
while(y*z>0 && y%10==z%10)
{
y/=10;
z/=10;
}
if(y+z==0)
cout<<1;
else
cout<<0;
}

You might also like