-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcondition.cpp
58 lines (47 loc) · 1.2 KB
/
condition.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
// Write Your Code Here
string word[10] = {"" , "one" , "two" , "three" , "four" , "five" , "six" ,"seven" , "eight" , "nine" };
if(n>=1 && n<=9)
{
cout << word[n];
}
else
cout << "Greater than 9";
return 0;
}
// Variable Sized
#include <iostream>
#include <vector>
using namespace std;
int main() {
// get length of array 'a' and number of queries
int n, q;
cin >> n >> q;
// create vector of vectors
vector<vector<int>> a(n);
// fill each 2D vector i with k_i values
for (int i = 0; i < n; i++) {
// get the length k of the vector at a[i]
int k;
cin >> k;
// fill the vector with k values
a[i].resize(k);
for (int j = 0; j < k; j++) {
cin >> a[i][j];
}
}
// run queries on a
for (int q_num = 0; q_num < q; q_num++) {
// get i, j as the 'query' to get a value from a
int i, j;
cin >> i >> j;
cout << a[i][j] << endl;
}
return 0;
}