Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- char vectorCuv[100][101];
- int totalCuv = 0;
- char text[101]; // testez validez utilizez date corecte acum
- cin.getline(text, 101);
- char *cuvant = strtok(text, " ");
- while(cuvant != NULL)
- {
- strcpy(vectorCuv[totalCuv], cuvant);
- totalCuv++;
- cuvant = strtok(NULL, " ");
- }
- int inserari = 0;
- for(int i = 0; i < totalCuv - 1; i++)
- {
- char uc1 = vectorCuv[i][strlen(vectorCuv[i]) - 1];
- char uc2 = vectorCuv[i + 1][strlen(vectorCuv[i + 1]) - 1];
- if(uc1 == uc2)
- {
- for(int j = totalCuv; j > i; j--)
- strcpy(vectorCuv[j], vectorCuv[j - 1]);
- strcpy(vectorCuv[i + 1], "succes");
- totalCuv++;
- inserari++;
- }
- }
- strcpy(text, "");
- for(int i = 0; i < totalCuv - 1; i++)
- {
- strcat(text, vectorCuv[i]);
- strcat(text, " ");
- }
- if(inserari != 0)
- cout << text;
- else
- cout << "nu exista";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement