MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

Hackerrank_problems/diagonal-difference/solution.cpp:38–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38int main()
39{
40 ofstream fout(getenv("OUTPUT_PATH"));
41
42 string n_temp;
43 getline(cin, n_temp);
44
45 int n = stoi(ltrim(rtrim(n_temp)));
46 //initialize the array
47 vector<vector<int>> arr(n);
48
49 for (int i = 0; i < n; i++) {
50 arr[i].resize(n);
51
52 string arr_row_temp_temp;
53 getline(cin, arr_row_temp_temp);
54
55 vector<string> arr_row_temp = split(rtrim(arr_row_temp_temp));
56
57 for (int j = 0; j < n; j++) {
58 int arr_row_item = stoi(arr_row_temp[j]);
59
60 arr[i][j] = arr_row_item;
61 }
62 }
63
64 int result = diagonalDifference(arr,n);
65
66 fout << result << "\n";
67
68 fout.close();
69
70 return 0;
71}
72
73string ltrim(const string &str) {
74 string s(str);

Callers

nothing calls this directly

Calls 4

ltrimFunction · 0.70
rtrimFunction · 0.70
splitFunction · 0.70
diagonalDifferenceFunction · 0.70

Tested by

no test coverage detected