Instructions - Describe the code! Stanford University
  • This instruction set will continue to grow once the main round is posted, keep checking back.
  • Note that these are just examples, we encourage you to use your own grammar or descriptions!

1Declarations
  • string v[200];
    • v = array of strings of length 200
    • let v = string array of length 200
    • let v be of array of length 200 of strings
  • int n, m;
    • n, m = integers
    • create integers n and m
  • map<string, int> mp;
    • let mp be a map from string to int
    • create a map mp from strings to ints
    • mp = map from string to int
  • int n, a, maxi = 0;
    • let n, a, maxi be integers with maxi = 0
    • n, a, maxi = integers with maxi = 0
2Input & output
  • cin >> n >> m;
    • Read n and m
  • cout << (sx + tx) / 2 + 1 << " " << (sy + ty) / 2 + 1;
    • print (sx + tx) / 2 + 1 and (sy + ty) / 2 + 1
    • print (sx + tx) / 2 + 1, " ", (sy + ty) / 2 + 1
  • cout << sum << endl
    • print sum and a new line
    • print sum
3Function
  • int main()
    • in the main function
    • in function main
  • maxi = max(maxi, m[a]);
    • set maxi to max of maxi and m[a]
    • maxi = max(maxi, m[a])
4Loops
  • for (int i = 0; i < n; ++i)
    • for i = 0 to n exclusive
    • for i = 0 to n (exclusive)
  • for (int i = 0; i < a.size(); i++)
    • for i = 0 to length of a exclusive
5Conditionals
  • if (!first && v[i][j] == 'B') {
    • if not first and v[i][j] is B
    • if first is false and v[i][j] is the character B
  • if (v[i][j] == 'B') {
    • if v[i][j] is B
    • if v[i][j] is character B
    • if v[i][j] is equal to B, do the following.
  • } else if (i + 1 == n)
    • else if i + 1 = n do the following
    • else if i + 1 is equal to n
  • int n, m;
    • n, m = integers
    • create integers n and m
6Assignments
  • sx = i;
    • set sx to i
    • sx = i
    • assign i to sx
  • a = abs(b[i] - c[j])
    • set x to absolute value of b[i] - c[j]
7Other operations
  • sum++
    • increment sum
    • add 1 to sum
    • increase sum by 1
  • x = a && b
    • set x to a and b
    • set x to a && b
    • x = a and b