Jump to content
androidr1

C++ siruri

Recommended Posts

Posted

Doresc scoaterea vocalelor dintr-un sir de caractere, insa ceva nu merge.

#include<iostream>

using namespace std;

char s[100],vocale[]={"aeiouAEIOU"};

int i

int main()

{

cin.getline(s,200);

for(i=0;i<strlen(s);i++)

if(strchar(vocale,s))

strcpy(s+i;s+i+1)

}

Posted
#include <iostream>
using namespace std;

int main() {
char *ginel;
ginel = new char();

cout << "Introdu textul: " << endl;
cin >> ginel;

for (int i=0;ginel[i]!='\0';i++) {
if (ginel[i]=='a' || ginel[i]=='e' || ginel[i]=='i' || ginel[i]=='o' || ginel[i]=='u' || ginel[i]=='A' || ginel[i]=='E' || ginel[i]=='I' || ginel[i]=='O' || ginel[i]=='U') { ginel[i]=' '; }
}
cout << ginel;
return 0;
}

Posted

sau asa


#include <iostream>
#include <string.h>
using namespace std;

int main() {
char *ginel;
ginel = new char();
char vocale[]={"aeiouAEIOU"};
cout << "Introdu textul: " << endl;
cin >> ginel;
for (int i=0;ginel[i]!='\0';i++) {
if(strchr(vocale,ginel[i])) { ginel[i]=' '; }
}
cout << ginel;
return 0;
}

  • Active Members
Posted (edited)

Cum adica doresti scoaterea lor ? Si ce nu merge ?

Vezi ca nu ai pus

;

dupa

int i

.

Nu exista strchar ci strchr

Uite aici o idee:


int main()
{
char s[51], v[]="aeiouAEIOU"; int i,k=0;//am definit in sirul v vocalele mici si mari din alfabet
cout<<"Introduceti sirul: "; cin.get(s,50);
for(i=0;s[i]!=0;i++)
if(strchr(v,s[i])!=0) //s[i] este vocala
k++;
cout<<"Sirul contine "<<k<<" vocale";
return 0;
}

Edited by MrGrj
Posted

#ifdef _MSC_VER

#define _CRT_SECURE_NO_WARNINGS

#endif

#include <iostream>

#include <cstring>

using namespace std;

int main()

{

char s[100], vocale[] = { "aeiouAEIOU" };

cin.getline(s, 200);

for (int i = 0, k = strlen(s); i < k; i++)

if (strchr(vocale, s))

strcpy(s + i, s + i + 1);

cout << s << endl;

return 0;

}

Posted

sau asa

#include <iostream>
#include <cstring>
using namespace std;


int main(){
int i = 0, prag = 0;
char vocale[]={"aeiouAEIOU"};
char temp[100], *ginel;
ginel = new char();
cout << "Introdu textul: " << endl;
cin >> ginel;
while (ginel[i]!= '\0'){
if(!strchr(vocale,ginel[i])) {
temp[prag++] = ginel[i];
}
else
{
temp[prag] = ginel[i];
}
i++;
}
temp[prag+1] = '\0';
cout << temp << "\n";
}

Output:

root@superstars:~# ./vow
Introdu textul:
manca-ti-as
mnc-t-s

Posted

In programul scris de tine, functia care trebuie folosita este "STRCHR" care iti cauta un caracter/caractere intr-un sir.

Uite aici ceva mai usor:

int main(){

char sir[256]

cin.get(sir,255);

char voc[]="aeiouAEIOU";

for(int i=0;i<=strlen(sir)-1;i++)

if(strchr(voc,sir)!=NULL)

strcpy(sir+i,sir+i+1);

cout<<sir;

return 0;

}

In acest caz, iti elimina si vocalele mari cat si cele mici.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...