-
Build system in Sublime
{ "cmd": ["g++.exe", "-std=c++14", "${file}", "-o", "${file_base_name}.exe", "", "${file_base_name}.exe
outputf.in"], "shell": true, "working_dir": "${file_path}", "selector": "source.cpp", "variants": [ { "name": "Run", "cmd": ["cmd", "/C", "echo '${file_base_name}, it's build success :)'"], "shell": true, "working_dir": "${file_path}" } ] } - Multidimensional Array
{ int R, C;
cin >> R >> C;
// Input matrix A int A[100][100];
for (int i = 0; i < R; i++) {
for (int j = 0; j < C; j++) {
cin >> A[i][j];
} }
// Input matrix B int B[100][100];
for (int i = 0; i < R; i++) {
for (int j = 0; j < C; j++) {
cin >> B[i][j];
} } // Call the function to add matrices A and B addMatrices(A, B, R, C, 0, 0);
// Print the resulting matrix for (int i = 0; i < R; i++) {
for (int j = 0; j < C; j++) {
cout << A[i][j] << " ";
} cout << endl;
} return 0;
1D Array
#include
using namespace std;
const int MAX_SIZE = 100;
int main() {
int n;
int arr[MAX_SIZE];
cout << "Enter the size of the array (up to " << MAX_SIZE << "): ";
cin >> n;
cout << "Enter " << n << " integers: ";
for (int i = 0; i < n; i++) {
cin >> arr[i];
} cout << "The array contains: ";
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
} cout << endl;
return 0;
}
Tuesday, May 9, 2023
Competitive Programming
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment