Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
using namespace std;
int main() {
const int SIZE = 50;
int array1[SIZE], array2[SIZE];
int insertionIterations = 0, shellIterations = 0;
srand(time(0));
for (int i = 0; i < SIZE; i++) {
#include <iostream>
using namespace std;
int main() {
const int SIZE = 10;
int arr[SIZE];
cout << "Enter " << SIZE << " array elements:" << endl;
for (int i = 0; i < SIZE; i++) {
cin >> arr[i];
}
#include <iostream>
using namespace std;
int main() {
int size;
cout << "Enter array size: ";
cin >> size;
if (size <= 0) {
#include <iostream>
int main() {
const int SIZE = 15;
int arr[SIZE];
std::cout << "Array: ";
for (int i = 0; i < SIZE; ++i) {
arr[i] = std::rand() % 100 + 1;
#include <iostream>
int main() {
int size;
std::cout << "Enter array size: ";
std::cin >> size;
if (size <= 0) {
std::cerr << "The array size must be positive." << std::endl;
return 1;
#include <iostream>
int main() {
const int SIZE = 10;
int arr[SIZE];
std::cout << "Enter 10 integers: ";
for (int i = 0; i < SIZE; ++i) {
std::cin >> arr[i];
}
#include <iostream>
int main() {
const int SIZE = 17;
int arr[SIZE];
std::cout << "Enter 17 two-digit integers: ";
for (int i = 0; i < SIZE; ++i) {
std::cin >> arr[i];
if (arr[i] < 10 || arr[i] > 99) {
1)
#include <iostream>
using namespace std;
int main() {
int rows, cols, start;
cout << "Enter the number of rows: ";
cin >> rows;
1)
#include <iostream>
using namespace std;
int main() {
const int ROWS = 3;
const int COLS = 3;
int arr[ROWS][COLS];
#include <iostream>
using namespace std;
int main() {
const int rows = 3, cols = 4;
int arr[rows][cols] = {
{3, 5, 6, 7},
{12, 1, 1, 1},
{0, 7, 12, 1}
};