bogdanNiculeasa

prefixe(2 variante de fiecare)

Jan 11th, 2023
787
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include<string.h>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.     char s[11];
  10.     cin >> s;
  11.  
  12.     // Varianta complicaciune
  13.     /*for (int i = strlen(s); i >= 0; i--) {
  14.         char temp[11];
  15.         strncpy(temp, s, i);
  16.         temp[i] = '\0';
  17.         cout << temp;
  18.         if (i != 0) {
  19.             cout << endl;
  20.         }
  21.     }*/
  22.  
  23.     for (int i = 0; i < strlen(s); i++) {
  24.         for (int j = 0; j < (strlen(s) - i); j++) {
  25.             cout << s[j];
  26.         }
  27.         cout << endl;
  28.     }
  29.     cout << "-----" << endl;
  30.     // Varianta complicaciune
  31.     //for (int i = 0; i < strlen(s); i++) {
  32.     //    char temp[11];
  33.     //    strcpy(temp, s + i);
  34.     //    cout << temp << endl;
  35.     //}
  36.  
  37.     for (int i = 0; i < strlen(s); i++) {
  38.         for (int j = i; j < strlen(s); j++) {
  39.             cout << s[j];
  40.         }
  41.         cout << endl;
  42.     }
  43.  
  44.     return 0;
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment