androidr1 Posted December 26, 2014 Report Posted December 26, 2014 Doresc scoaterea vocalelor dintr-un sir de caractere, insa ceva nu merge.#include<iostream>using namespace std;char s[100],vocale[]={"aeiouAEIOU"};int iint main(){ cin.getline(s,200); for(i=0;i<strlen(s);i++) if(strchar(vocale,s)) strcpy(s+i;s+i+1)} Quote
JIHAD Posted December 26, 2014 Report Posted December 26, 2014 #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;} Quote
JIHAD Posted December 26, 2014 Report Posted December 26, 2014 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;} Quote
Active Members MrGrj Posted December 26, 2014 Active Members Report Posted December 26, 2014 (edited) Cum adica doresti scoaterea lor ? Si ce nu merge ?Vezi ca nu ai pus; dupa int i .Nu exista strchar ci strchrUite 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 December 26, 2014 by MrGrj Quote
H3xoR Posted December 26, 2014 Report Posted December 26, 2014 #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;} Quote
JIHAD Posted December 26, 2014 Report Posted December 26, 2014 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:~# ./vowIntrodu textul: manca-ti-asmnc-t-s Quote
raduandrei1G Posted December 26, 2014 Report Posted December 26, 2014 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. Quote