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>1.
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;
}
#include<iostream>2.
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";
}
#include<iostream>3.
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;
}
}
#include<iostream>4.
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";
}
#include<iostream>5.
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";
}
#include<iostream>6.
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];}
}
#include<iostream>7.
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";
}
#include<iostream>8.
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;
}
#include<iostream>9.
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;}
}
#include<iostream>10.
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;
}
#include<iostream>11.
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;}
}
#include<iostream>12.
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;
}
#include<iostream>13.
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;
}
#include<iostream>14.
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;
}
#include<iostream>15.
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;
}
#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;
}