djelad1

Untitled

Dec 5th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. switch (option)
  2. {
  3. case 2:
  4. {
  5. char text1[LINES2][MAX_LETTERS2];
  6. char text2[LINES2][MAX_LETTERS2];
  7. char text3[LINES2][MAX_LETTERS2];
  8. int i = 0, lettersCounter = 0, sum1=0, sum2=0, sum3=0;
  9. cout << "Please fill text 1 with " << LINES2 << " lines and max " << MAX_LETTERS2 << " letters" << endl;
  10. for (i = 0; i <= LINES2; i++)
  11. cin.getline(text1[i], MAX_LETTERS2);
  12. cout << "Please fill text 2 with " << LINES2 << " lines and max " << MAX_LETTERS2 << " letters" << endl;
  13. for (i = 0; i < LINES2; i++)
  14. cin.getline(text2[i], MAX_LETTERS2);
  15. while (i < LINES2)
  16. {
  17. sum1 = strlen(text1[0]) + strlen(text2[0]);
  18. sum2 = strlen(text1[1]) + strlen(text2[1]);
  19. sum3 = strlen(text1[2]) + strlen(text2[2]);
  20. if (sum1 < MAX_LETTERS2)
  21. {
  22. strcpy_s(text3[0], text1[0]);
  23. strcat_s(text3[0], text2[0]);
  24. }
  25. if (sum2 < MAX_LETTERS2)
  26. {
  27. strcpy_s(text3[1], text1[1]);
  28. strcat_s(text3[1], text2[1]);
  29. }
  30. if (sum3 < MAX_LETTERS2)
  31. {
  32. strcpy_s(text3[2], text1[2]);
  33. strcat_s(text3[2], text2[2]);
  34. }
  35. i++;
  36. }
  37. cout << "text 3 is : \n";
  38. for (i = 0; i < LINES2; i++)
  39. cout << text3[i];
  40. cout << endl;
Advertisement
Add Comment
Please, Sign In to add comment