Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int nb = 0, nc = 0;
- bool contains(int *a, int size, int value){
- for (int i = 0; i < size; i++)
- if (a[i] == value)
- return 1;
- return 0;
- }
- bool strcmp(char *str1, char *str2){
- int i = 0;
- bool flag = 1;
- while ((str1[i] != '\0') || (str2[i] != '\0')) {
- i++;
- if (str1[i] != str2[i]){
- flag = 0;
- break;
- }
- }
- if (flag == 0)
- return 0;
- else
- return 1;
- }
- void strcopy(char *str1, char *str2){
- int i = 0;
- while (str2[i] != '\0') {
- str1[i] = str2[i];
- i++;
- }
- }
- int main(){
- int na = 0;
- cin >> na;
- int *a = new int[na];
- for (int i = 0; i < na; i++)
- cin >> a[i];
- cout << contains(a, na, 4) << endl;
- int nb = 0, nc = 0;
- cin >> nb >> nc;
- char *b = new char[nb];
- char *c = new char[nc];
- for (int i = 0; i < nb; i++)
- cin >> b[i];
- for (int i = 0; i < nc; i++)
- cin >> c[i];
- cout << strcmp(b, c) << endl;;
- strcopy(b, c);
- for (int i = 0; i < nc; i++)
- cout << b[i];
- cout << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement