Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 6

Problema 12:

#include <iostream>
#include <cstring>
using namespace std;
int i;
char s[256];
int main()
{
cin.getline(s,256);
for(i=0;i<strlen(s);i++)
{
if(i==0&&s[i]>=97&&s[i]<=125)
s[i]=s[i]-32;
if(i>0)
{
if(s[i]>=65&&s[i]<=125&&(s[i-1]==32||s[i+1]==32||s[i+1]==NULL))
s[i]=s[i]-32;
}
}
cout<<s;
return 0;
}

Problmea 2803:

#include <iostream>//2803
#include <cstring>
using namespace std;
int p,l,i;
char s[256],m[256],aux[256];
int main(){
cin>>p>>s;
l=strlen(s);
for(i=0;i<=l-p;i++){
strcpy(m,s);
strcpy(aux,s+i+p);
strcpy(s+i,aux);
cout<<s<<endl;
strcpy(s,m);
}
return 0;
}

Problema 101:

#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin("sortcuv.in");
ofstream fout("sortcuv.out");
int j,i,n;
char v[251][251],*p,s[251],aux[251];
int main(){
fin.getline(s,251);
p=strtok(s," ");
while(p){
strcpy(v[i],p);
i++;
p=strtok(NULL," ");
}
n=i;
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(strcmp(v[i],v[j])>0)
{
strcpy(aux,v[i]);
strcpy(v[i],v[j]);
strcpy(v[j],aux);
}
for(i=0;i<n;i++)
fout<<v[i]<<endl;
return 0;
}

Problema 2813:

#include <iostream>
#include <cstring>
using namespace std;
char verif[8][4]= {"DO","RE","MI","FA","SOL","LA","SI"},s[101],*p;
int j,i,n;
int main(){
cin.getline(s,101);
p=strtok(s," ");
int ok=0,k=0;
while(p){
ok=0;
for(i=0;i<=6;i++)
if(strstr(p,verif[i])!=0)
ok=1;
if(ok==1){
k++;
cout<<p<<endl;}
p=strtok(NULL," ");
}
if(k==0)
cout<<"nu exista";
return 0;
}

😊Problema 104:😊

#include <iostream>
#include <cstring>
using namespace std;
char s[256],aux[256],voc[]="aeiou";
int poz,lungime,j,i,n;
int main(){
cin.getline(s,256);
while(i<strlen(s))
{
lungime=0;
poz=i;
while(strchr(voc,s[i])!=0&&i<strlen(s))
{
i++;
lungime++;
}
if(lungime>=2){
strcpy(aux,s+poz+lungime);
strcpy(s+poz,aux);}
i=poz+1;
}
cout<<s;
return 0;
}

Problema 2673:

#include <iostream>
#include <cstring>
using namespace std;
int c,i,j,k,n;
char separator[256],s[256],*p,v[256][256];
int main(){
cin.getline(s,256);
for(i=1;i<256;i++)
if(!isalpha(i))
separator[c++]=i;
separator[c]=NULL;
p=strtok(s,separator);
int k=0;
while(p)
{
strcpy(v[k],p);
k++;
p=strtok(NULL,separator);
}
n=k-1;
j=n;
i=0;

while(i<j){
cout<<v[i]<<endl<<v[j]<<endl;
i++;
j--;
}
if(i==j)
cout<<v[i];
}

Problema 110:

#include <iostream>
#include <cstring>
using namespace std;
int i,j;
char s[101];
int main()
{
cin>>s;
for(i=0;i<strlen(s);i++){
j=0;
while(j<strlen(s))
{
if(i!=j)
cout<<s[j];
j++;
}
cout<<endl;}
}

Problema 188:

#include <iostream>
#include <cstring>
using namespace std;
char a[10],b[10],s[101],aux[256],*p;
int main()
{
cin>>a>>b;
cin.get();
cin.getline(s,101);
p=strtok(s," ");
while(p)
{
if(strcmp(p,a)==0)
strcat(aux,b);
else
strcat(aux,p);
strcat(aux," ");
p=strtok(NULL," ");
}
strcpy(s,aux);
cout<<s;
return 0;
}

Problema 232:

#include <iostream>
#include <cstring>
using namespace std;
int ok,i;
char s[101],aux[101],*p;
int main()
{
cin.getline(s,101);
p=strtok(s," ");
while(p)
{
ok=0;
for(i=0;i<strlen(p);i++)
if(isalpha(p[i])!=0)
ok=2;
if(ok==0){
for(i=0;i<strlen(p)&&ok!=1;i++)
{
if(i==0&&isdigit(p[i])!=0&&p[i+1]=='.'&&isdigit(p[i+2])!=0){
strcat(aux," ");
ok=1;}
if(i>=1)
if(isdigit(p[i-1])!=0&&p[i]=='.'&&isdigit(p[i+1])!=0){
strcat(aux," ");
ok=1;}
}}
if(ok==0||ok==2){
strcat(aux,p);
strcat(aux," ");}
p=strtok(NULL," ");

}
strcpy(s,aux);
cout<<s;
}

You might also like