Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- void eliminaUltimulA(char a[],char c)
- {
- for(int i=strlen(a); i>=0; i--)
- {
- if (a[i]==c)
- {
- for (int j=i; a[j]!=0; j++)
- a[j]=a[j+1];
- break;
- }
- }
- }
- void pozitii(char s1[], char s2[])
- {
- int gasit=1;
- char *p=s1;
- while(gasit)
- {
- gasit=0;
- if (strstr(p,s2) !=0)
- {
- cout <<strstr(p,s2)-s1 << endl;
- p = strstr(p,s2)+1;
- gasit=1;
- }
- }
- }
- int numar_aparitii(char s1[], char s2[])
- {
- int c=0;
- int gasit=1;
- char *p=s1;
- while(gasit)
- {
- gasit=0;
- if (strstr(p,s2) !=0)
- {
- c++;
- p = strstr(p,s2)+1;
- gasit=1;
- }
- }
- return c;
- }
- int main()
- {
- char a[100]="Vrei sa pleci dar nu vrei sa ma iei sa vin cu tine.";
- pozitii(a," sa ");
- cout << numar_aparitii(a," sa ") << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement