#include <iostream>
int main() {
int arr[]{-1, 2, -3, 4, -6, -6, 7, -8, 9, 1};
for(int i{0}; i < std::size(arr); ++i) {
if(arr[i] > 0 && arr[i+1] < 0) {
std::cout << arr[i] << ' ' << arr[i+1] << ' ';
++i;
}
if(arr[i] < 0 && arr[i+1] > 0) {
std::cout << arr[i] << ' ' << arr[i+1] << ' ';
++i;
}
}
return 0;
}
#include <iostream>
template <typename T>
void commonElem(T a[], T a2[], T a3[], int len, int len2, int len3) {
std::cout<<"Common elements arrays is: ";
for(int i{0}; i < len; ++i) {
bool f2{false}, f3{false};
for(int j{0}; j < len2; ++j) if(a[i] == a2[j]) f2 = true;
for(int k{0}; k < len3; ++k) if(a[i] == a3[k]) f3 = true;
if(f2 && f3) std::cout << a[i] << ' ';
}
}
int main() {
int arr[]{23,12,54,2,7}, arr2[]{2,23,1,65}, arr3[]{43,2,76,4,23,8,96};
int l = std::size(arr), l2 = std::size(arr2), l3 = std::size(arr3);
commonElem(arr, arr2, arr3, l, l2, l3);
return 0;
}
#include <iostream>
#include <string>
#include <sstream>
int main() {
std::string str;
std::cout << "Enter string: ";
std::getline(std::cin, str);
std::stringstream s(str);
std::string tmp, res;
int count = 0;
while(s >> tmp) {
res += tmp + ' ';
++count;
if(count%3==0) res += tmp + ' ';
}
res = res.substr(0, res.length()-1);
std::cout<<res;
return 0;
}