You are on page 1of 5

1.

#include <bits/stdc++.h>

using namespace std;

char s[256], t[256];


int nr, a[10];

int main()
{
cin>>s>>t;
for(int i=0; i<strlen(s); i++)
if(strchr("0123456789", s[i])!=NULL && a[s[i]-'0']==0)
a[s[i]-'0']=1, nr=nr*10+(s[i]-'0');
for(int i=0; i<strlen(t); i++)
if(strchr("0123456789", t[i])!=NULL && a[t[i]-'0']==0)
a[t[i]-'0']=1, nr=nr*10+(t[i]-'0');
cout<<nr;
return 0;
}
2.
a)
#include <bits/stdc++.h>

using namespace std;

struct melodie
{
char nume[30], autor[20], tara[20];
int loc_top, an_top;
}m[200];

int main()
{
for(int i=0; i<=200; i++)
cin>>m[i].nume>>m[i].autor>>m[i].tara>>m[i].loc_top>>m[i].an_top;
for(int i=0; i<=200; i++)
if(m[i].an_top==2018)
cout<<m[i].nume<<'\n';
return 0;
}
b)
#include <bits/stdc++.h>
using namespace std;

struct melodie
{
char nume[30], autor[20], tara[20];
int loc_top, an_top;
}m[200];

int main()
{
for(int i=0; i<=200; i++)
cin>>m[i].nume>>m[i].autor>>m[i].tara>>m[i].loc_top>>m[i].an_top;
for(int i=0; i<=200; i++)
for(int j=i+1; j<=200; j++)
if(strcmp(m[i].nume, m[j].nume)>0)
swap(m[i], m[j]);
for(int i=0; i<=200; i++)
cout<<m[i].nume<<' ';
return 0;
}
c)
#include <bits/stdc++.h>

using namespace std;

struct melodie
{
char nume[30], autor[20], tara[20];
int loc_top, an_top;
}m[200];

int main()
{
for(int i=0; i<=200; i++)
cin>>m[i].nume>>m[i].autor>>m[i].tara>>m[i].loc_top>>m[i].an_top;
for(int i=0; i<=200 i++)
for(int j=i+1; j<=200; j++)
if(strcmp(m[i].tara, m[j].tara)>0)
swap(m[i], m[j]);
else
if(strcmp(m[i].tara, m[j].tara)==0)
if(m[i].loc_top>m[j].loc_top)
swap(m[i], m[j]);
for(int i=0; i<=200; i++)
cout<<m[i].nume<<' ';
return 0;
}
3.
#include <bits/stdc++.h>

using namespace std;

void numere(int n, int v[], int &suma)


{
suma=0;
int ok=0;
for(int i=1; i<=n; i++)
{
int x=v[i], s=0;
while(x>9)
s+=x%10, x/=10;
if(x==s)
suma+=v[i], ok=1;
}
if(!ok)
suma=-1;
}

int n, v[101], s;

int main()
{
cin>>n;
for(int i=1; i<=n; i++)
cin>>v[i];
numere(n, v, s);
cout<<s;
return 0;
}
4.
#include <bits/stdc++.h>

using namespace std;

int n;
int f(int n)
{
if(n<9)
return 1;
else
return 1+f(n/10);
}

int main()
{
cin>>n;
cout<<f(n);
return 0;
}
5.
#include <bits/stdc++.h>

using namespace std;

int maxim(int n)
{
int cm;
if(n==0)
cm=n;
else
cm=max(n%10, maxim(n/10));
return cm;
}

int main()
{
int n;
cin>>n;
cout<<maxim(n);
return 0;
}

6.
int f(int a, int b)
{
if(b==0)
return a;
else
return f(b, a%b);
}-cmmdc al numerelor a, b
f(120, 80)
Afiseaza: 40
7.
int f(int a, int b)
{
if(b==0)
return 1;
else
return a*f(a,b-1);
}-a la b
8.c
9.
if(strlen(s1)<strlen(s2))
cout<<s1;
else
cout<<s2;
10.d
11.
#include <bits/stdc++.h>

using namespace std;

struct timp
{
int minut;
int secunda;
} start,stop;

int main()
{
cin>>start.minut>>start.secunda>>stop.minut>>stop.secunda;
start.minut*=60;
stop.minut*=60;
if(start.minut+start.secunda<stop.minut+stop.secunda)
cout<<"acceptat";
else
cout<<"respins";
return 0;
}

You might also like