1.Fie definitia urmatoare: struct fractie {int numitor,numarator;}; a) declarati variabilele f1,f2,f, de tipul definit mai sus; b) initializati variabila f cu suma fractiilor f1 si f2
#include<iostream>2.Scrieti un program in care se citeste de la tastatura un cuvant. Inlocuiti fiecare vocala cu consoana care o urmeaza si fiecare consoana cu vocala care o precede.
using namespace std;
struct fractie
{int numitor,numarator;};
int main()
{fractie f1,f2,f;
int a,b;
cin>>f1.numarator>>f1.numitor;
cin>>f2.numarator>>f2.numitor;
f.numitor=f1.numitor*f2.numitor;
f.numarator=f2.numitor*f1.numarator+f2.numarator*f1.numitor;
a=f.numarator;
b=f.numitor;
while(a!=b)
{if(a>b)a=a-b;
else b=b-a;}
f.numarator=f.numarator/a;
f.numitor=f.numitor/b;
cout<<f1.numarator<<"/"<<f1.numitor<<"+"<<f2.numarator<<"/"<<f2.numitor<<"="<<f.numarator<<"/"<<f.numitor;
}
#include<iostream>3.Dintr-un fisier text se citesc un numar n si n+1 cuvinte. Afisati-le pe acelea care incep cu ultimul.
using namespace std;
struct fractie
{int numitor,numarator;};
int main()
{char a[100],j;
int i;
cin>>a;
for(i=0;i<strlen(a);i++)
if(strchr("aeiou",a[i]))
a[i]=a[i]+1;
else for(j=a[i];j>='a';j--)
if(strchr("aeiou",j))
{a[i]=j;break;}
cout<<a;
}
#include<iostream>4. Bork Bork Bork! (1-7)
#include<fstream>
using namespace std;
ifstream f("date");
int main()
{int n,i,j,k;
char t[100][100];
f>>n;
for(i=0;i<=n;i++)
f>>t[i];
for(i=0;i<n;i++)
if(strstr(t[i],t[n])==t[i])
cout<<t[i]<<endl;
}
#include<iostream>
#include<fstream>
using namespace std;
int main()
{char a[100],*p;
int n,i,j,k;
cin.get(a,100);
n=strlen(a);
p=strstr(a,"THE");
while(strstr(a,"THE"))
{a[strstr(a,"THE")-a]='Z';
a[strstr(a,"ZHE")-a+1]='E';}
while(strstr(a,"AN"))
a[strstr(a,"AN")-a]='U';
while(strstr(a,"AU"))
{a[strstr(a,"AU")-a]='O';
a[strstr(a,"OU")-a]='O';}
for(i=0;i<n;i++)
if(a[i]=='A' && a[i+1]!=' ')
a[i]='E';
while(strstr(a,"OW"))
a[strstr(a,"OW")-a+1]='O';
for(i=0;i<n;i++)
if(a[i]=='O')
a[i]='U';
strcat(a,"Bork Bork Bork!");
cout<<a;
}