Advertisement
noler89

Untitled

Dec 11th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int nb = 0, nc = 0;
  5. bool contains(int *a, int size, int value){
  6. for (int i = 0; i < size; i++)
  7. if (a[i] == value)
  8. return 1;
  9. return 0;
  10. }
  11. bool strcmp(char *str1, char *str2){
  12. int i = 0;
  13. bool flag = 1;
  14. while ((str1[i] != '\0') || (str2[i] != '\0')) {
  15. i++;
  16. if (str1[i] != str2[i]){
  17. flag = 0;
  18. break;
  19. }
  20. }
  21. if (flag == 0)
  22. return 0;
  23. else
  24. return 1;
  25. }
  26. void strcopy(char *str1, char *str2){
  27. int i = 0;
  28. while (str2[i] != '\0') {
  29. str1[i] = str2[i];
  30. i++;
  31. }
  32. }
  33. int main(){
  34. int na = 0;
  35. cin >> na;
  36. int *a = new int[na];
  37. for (int i = 0; i < na; i++)
  38. cin >> a[i];
  39. cout << contains(a, na, 4) << endl;
  40.  
  41. int nb = 0, nc = 0;
  42. cin >> nb >> nc;
  43. char *b = new char[nb];
  44. char *c = new char[nc];
  45. for (int i = 0; i < nb; i++)
  46. cin >> b[i];
  47. for (int i = 0; i < nc; i++)
  48. cin >> c[i];
  49. cout << strcmp(b, c) << endl;;
  50. strcopy(b, c);
  51. for (int i = 0; i < nc; i++)
  52. cout << b[i];
  53. cout << endl;
  54. system("pause");
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement