Orar semigroup #2

Orar semigroup #2

[REZOLVARI]24 noiembrie + Recapitulare teza

Se citesc doua siruri de la tastatura. Sa se scrie un program care sa afiseze toate literele mici care apar in ambele siruri o singura data.

#include<iostream>
using namespace std;
int main()
{int i,k=0;
char a[100],b[100],aux[100]={0};
cin>>a;
cin>>b;
for(i=0;i<strlen(a);i++)
    if(islower(a[i]))
        if(strchr(aux,a[i])==0)
            if(strchr(b,a[i]))
                {aux[k]=a[i];k++;}
aux[k]=0;
cout<<aux;
}
1.
#include<iostream>
using namespace std;
int main()
{int i,k=0;
char *p,a[100],b[100],aux[100]={0};
cin.get(a,100);
p=a;
while(*p)
    {k++;p++;}
cout<<k<<" elemente";
}
2.
#include<iostream>
using namespace std;
int main()
{int i,k=1;
char *p,a[100],b[100],aux[100]={0};
cin.get(a,100);
i=0;k=1;
while(k<=strlen(a))
{
    i=0;
while(i<k)
    {cout<<a[i];
   
    i++;}
    k++;
    cout<<endl;
}
}
3.
 #include<iostream>
using namespace std;
int main()
{int i,k=1;
char *p,a[100],b[100],aux[100]={0};
cin.get(a,100);
cin.get();
cin.get(b,100);
if(a[strlen(a)-1] == b[strlen(b)-1])
    if(a[strlen(a)-2] == b[strlen(b)-2])
        cout<<"Rimeaza";
    else cout<<"NU";
else cout<<"NU";
}
4.
#include<iostream>
using namespace std;
int main()
{int i=0,j=0,k=1;
char *p,a[100],b[100],aux[100]={0};
cin.get(a,100);
for(p=a;*p;p++)
{    if(strchr("AEIOUaeiou",*p))
        i++;
    if(strchr("AEIOUaeiou",*p)==0)
        j++;
}
cout<<i<<" Vocale "<<j<<" Consoane";
}
5.
#include<iostream>
using namespace std;
int main()
{char s[100],a[100];
int i,j;
cin>>s;
cin>>a;
for(i=0;i<strlen(s);i++){
for(j=0;j<strlen(a);j++)
if(islower(s[i]) && islower(a[j]) && s[i]==a[j])
cout<<s[i];}
}
6.
#include<iostream>
using namespace std;
int main()
{int n,nn,i;
char aux,a[100],b[100],*p,*q,m[1][100];
for(i=0;i<2;i++)
    cin>>m[i];
strcpy(a,m[0]);
strcpy(b,m[1]);

for(p=a;*p;p++)
    for(q=a+1;*q;q++)
        if(*p>*q)
            {aux=*p;
            *p=*q;
            *q=aux;}
                      
for(p=b;*p;p++)
    for(q=b+1;*q;q++)
        if(*p>*q)
            {aux=*p;
            *p=*q;
            *q=aux;}
          
if(strcmp(a,b)==0)
    cout<<"DA";
else cout<<"NU";

}
7.
#include<iostream>
using namespace std;
int main()
{int i=0,j,n,k,x[26]={0},y[26];
char a[100],*p,aux;
cin.get(a,100);
strupr(a);
for(p=a;*p;p++)
    if(isalpha(*p))
        {x[*p-'A']++;
         i++;}

for(j=0;j<26;j++)
    cout<<(char)(j+'A')<<" apare de "<<x[j]<<" ori"<<endl;
cout<<endl;

}
8.
#include<iostream>
using namespace std;
int main()
{char v[100]="AEIOUaeiou",a[100],*p;
cin.get(a,100);
for(p=a;*p;p++)
    if(*(p+1)!=NULL && *(p+2)!=NULL)
    if(strchr(v,*p))
        if(strchr(v,*(p+1)) && strchr(v,*(p+2)))
            {cout<<*p<<" "<<*(p+1)<<" "<<*(p+2);
            cout<<endl;}
}
9.
#include<iostream>
using namespace std;
int main()
{int i,j=0,k;
char v[100]="AEIOUaeiou",a[100],*p,t[100][100];
cin>>a;
for(i=0;i<strlen(a);i++)
{    strcpy(t[j],a+i);
    j++;
}
for(k=j;k>=0;k--)
    cout<<t[k]<<endl;
}
10.
#include<iostream>
using namespace std;
int main()
{int i,j=0,k;
char v[100]="AEIOUaeiou",a[100],*p,t[100][100],c;
cin.get(a,100);
for(i=0;i<strlen(a);i++)
    if(a[i]==c)
        {cout<<"Prima aparitie pe pozitia: "<<i;break;}
cout<<endl;
for(i=strlen(a)-1;i>=0;i--)
    if(a[i]==c)
    {cout<<"Ultima aparitie pe pozitia: "<<i;break;}
   
}
11.
#include<iostream>
using namespace std;
int main()
{int i,j=0,k;
char v[100]="AEIOUaeiou",a[100],b[100],*p,t[100][100],c;
cin.get(a,100);
for(p=a;*p;p++)
{    b[j]=*p;j++;
    if(strchr(v,*p))
        {b[j]='p';j++;
        b[j]=*p;j++;}
}
b[j]=0;
cout<<b;
}
12.
#include<iostream>
using namespace std;
int main()
{int i,j=-1,k=0,d,n,m;
char a[100],b[100]={0},t[100][100];
cin.get(a,100);
d=0;
while(a[i]==' ')
    d++;
for(i=d;i<strlen(a);)
{    if(a[i]!=' ')
        j++;
    k=0;
    while(a[i]!=' ')
        { t[j][k]=a[i];
          k++;
          i++;
        }
    i++;
}

for(i=0;i<=j;i++)
    cout<<t[i]<<endl;
strcpy(b,t[0]);


for(i=0;i<=j;i++)
{n=strlen(b);
m=strlen(t[i]);
    if(m>n)
        strcpy(b,t[i]);
}
cout<<"Cel mai lung cuvant "<<b;
}
13.
#include<iostream>
using namespace std;
int main()
{int i,j=-1,k=0,d,n,m;
char a[100],b[100]={0},t[100][100],aux[100];
cin>>n;
for(i=0;i<n;i++)
{    cin>>a;
    strcpy(t[i],a);
}
cout<<endl;
for(i=0;i<n-1;i++)
    for(j=i+1;j<n;j++)
    {    strcpy(a,t[i]);
        strcpy(b,t[j]);
        if(strcmp(a,b)>0)
        {    strcpy(aux,a);
            strcpy(a,b);
            strcpy(b,aux);
        }
        strcpy(t[i],a);
        strcpy(t[j],b);
    }
   
for(i=0;i<n;i++)
    cout<<t[i]<<endl;
}
14.
#include<iostream>
using namespace std;
int main()
{int i,j=-1,k=0,d,n,m;
char a[100],b[100]={0},t[100][100],aux[100],*p;
cin.get(a,100);
d=0;
while(a[d]==' ')
    d++;
while(a[d]!=' ')
    d++;
while(a[d]==' ')
    d++;

for(i=0;i<d;i++)
    cout<<a[i];

p=a+d+1;
while(*p!=' ')
    strcpy(p,p+1);
   
cout<<p;
}
15.
#include<iostream>
using namespace std;
int main()
{int i,j=-1,k=0,d,n,m;
char a[100],b[100]={0},t[100][100],aux[100],*p;
cin.get(a,100);
for(p=a;*p;)
    if(isupper(*p))
        strcpy(p,p+1);
    else p++;
cout<<a;
}

marți, 23 noiembrie 2010 by DlMuresan
Categories: , , , , | Leave a comment

Leave a Reply