Sunteți pe pagina 1din 8

SUBIECTUL 19

#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
int nr_aparitii(char s[70])
{ int i, k;
for(i=0;i<strlen(s)-1;i++)
if(s[i]==s[strlen(s)-1]) k++;
return k; }
int main()
{
ifstream f("atestat.in");
ofstream g("atestat.out");
char s[70], *p;
int i, k=0;
f.getline(s,71);
cout<<"nr aparitii ="<<nr_aparitii(s)<<endl;
for (i=0;i<strlen(s);i++)
if (strchr("aeiouAEIOU", s[i]))
s[i]=s[i]-32;
cout<<s<<endl;
p=strtok(s," ");
while(p)
{
if (strchr("aeiouAEIOU", p[strlen(p)-1])==0)
{
g<<p<<" ";
k=1;
}
p=strtok(NULL, " ");
}
if (k==0) g<<"NU EXISTA ASTFEL DE CUVINTE";
g.close();
f.close();
return 0;
}

SUBIECTUL 20
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
int nr_aparitii(char s[70])
{ int k=0;
char *p=strtok(s," ");
while(p)
{
k++;
p=strtok(NULL, " ");
}
return k;
}
int main()
{
ifstream f("atestat.in");
ofstream g("atestat.out");
char s[70], *p;
int i, k=0;
f.getline(s,71);
cout<<"nr cuvinte ="<<nr_aparitii(s)<<endl;
p=strtok(s," ");
while(p)
{
p[0]=p[0]-32;
cout<<p<<" ";
if (strchr("aeiouAEIOU", p[0]))
{
g<<p<<" ";
k=1;
}
p=strtok(NULL, " ");
}
if (k==0) g<<"NU EXISTA ASTFEL DE CUVINTE";
g.close();
f.close();
return 0;
}

SUBIECTUL 21
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
void stergere(char s[70])
{ int i;
for (i=0;i<strlen(s);i++)
if ('0'<=s[i] && s[i]<='9')
{
strcpy(s+i, s+i+1);
i--;
}
cout<<s<<endl;
}
int main()
{
ifstream f("atestat.in");
ofstream g("atestat.out");
char s[70], *p;
int i, k=0;
f.getline(s,71);
stergere(s);
for (i=0;i<strlen(s);i++)
if (strchr("aeiouAEIOU", s[i]))
s[i]=s[i]+32;
cout<<s<<endl;
p=strtok(s," ");
while(p)
{
if ( p[0]=='C')
{
g<<p<<" ";

k=1;
}
p=strtok(NULL, " ");
}
if (k==0) g<<"NU EXISTA ASTFEL DE CUVINTE";
g.close();
f.close();
return 0;
}

SUBIECTUL 22
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
void inlocuire(char s[70])
{ int i;
for (i=0;i<strlen(s);i++)
if (s[i]==' ')
s[i]=='_';
cout<<s<<endl;
}
int main()
{
ifstream f("atestat.in");
ofstream g("atestat.out");
char s[70], *p;
int i, k=0;
f.getline(s,71);
inlocuire(s);
for (i=0;i<strlen(s);i++)
if (strchr("aeiouAEIOU", s[i]))
s[i]=s[i]+32;
cout<<s<<endl;

p=strtok(s," ");
while(p)
{
p[strlen(p)-1]=p[strlen(p)-1]-32;
cout<<p<<" ";
if ( strlen(p)>=7)
{
g<<p<<" ";
k=1;
}
p=strtok(NULL, " ");
}
if (k==0) g<<"NU EXISTA ASTFEL DE CUVINTE";
g.close();
f.close();
return 0;
}

SUBIECTUL 23
#include <iostream>
#include <fstream>
using namespace std;
struct interval{
int x, y;};
int nr_intervale(interval a[20], int n)
{ int i, k;
for (i=0;i<n;i++)
if (a[i].x%2==0 && a[i].y%2==0)
k++;
return k;
}
int main()
{
ifstream f("atestat.in");
ofstream g("atestat.out");

interval a[20];
int i, k=0, n;
f>>n;
for(i=0;i<n;i++)
{f>>a[i].x>>a[i].y;
cout<<"["<<a[i].x<<", "<<a[i].y<<"]"<<endl;
}
cout<<"nr intervale="<<nr_intervale(a,n);
int max, min;
max=a[0].x; min=a[0].y;
for(i=0;i<n;i++)
{
if (max<a[i].x) max=a[i].x;
if (min>a[i].y) min=a[i].y;
}
if (max<min) g<<max<<" "<<min;
else g<<"NU EXISTA INTERVAL DE INTERSECTIE";
g.close();
f.close();
return 0;
}

SUBIECTUL 24
#include <iostream>
#include <fstream>
using namespace std;
struct obiect

{
int c, p;};
int valoare_totala(obiect a[20], int n)
{ int i, k=0;
for (i=0;i<n;i++)
k=k+a[i].c * a[i].p;
return k;
}

int main()
{
ifstream f("atestat.in");
ofstream g("atestat.out");
obiect a[20];
int i, k=0, n;
f>>n;
for(i=0;i<n;i++)
{f>>a[i].c>>a[i].p;
cout<<"("<<a[i].c<<", "<<a[i].p<<")"<<endl;
}
cout<<"valoare totala="<<valoare_totala(a,n);
int min;
min=a[0].p;
for(i=0;i<n;i++)
{
if (min>a[i].p)
}
for(i=0;i<n;i++)
if (a[i].p==min)

min=a[i].p;

g<<a[i].c<<endl;

g.close();
f.close();
return 0;
}
SUBIECTUL 25
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
struct punct

{
int x,y;};
void par(punct a[20], int n)

{ int i;
for (i=0;i<n;i++)
if(a[i].x%2==0) cout<<"("<<a[i].x<<","<<a[i].y<<")
}
int main()
{
ifstream f("atestat.in");
ofstream g("atestat.out");
punct a[20];
int i, k=0, n;
f>>n;
for(i=0;i<n;i++)
{f>>a[i].x>>a[i].y;
cout<<"("<<a[i].x<<", "<<a[i].y<<")"<<endl;
}
par(a,n);
for(i=0;i<n;i++)
{
if (a[i].x==a[i].y)
}
g<<k<<endl;
g.close();
f.close();
return 0;
}

k++;

";

S-ar putea să vă placă și