Language: C++

Last login: Thu Oct 18 20:56:45 on console
cd co  	asanomasakinoMacBook-Pro:~ asanomaki$ cd co
-bash: cd: co: No such file or directory
asanomasakinoMacBook-Pro:~ asanomaki$ cd atcoder/
asanomasakinoMacBook-Pro:atcoder asanomaki$ ls
abc
asanomasakinoMacBook-Pro:atcoder asanomaki$ cd abc/
asanomasakinoMacBook-Pro:abc asanomaki$ ls
a	a.out	b
asanomasakinoMacBook-Pro:abc asanomaki$ cd b
asanomasakinoMacBook-Pro:b asanomaki$ ls
42.cpp		copy.cpp	try.cpp
a.out		moji.cpp	try2.cpp
asanomasakinoMacBook-Pro:b asanomaki$ vim 50.cpp
asanomasakinoMacBook-Pro:b asanomaki$ g++ 50.cpp 
50.cpp:8:14: warning: variable 'm' is uninitialized when used here
      [-Wuninitialized]
        int t[n], p[m], x[m];
                    ^
50.cpp:7:10: note: initialize the variable 'm' to silence this warning
        int n, m;
                ^
                 = 0
50.cpp:8:8: warning: variable 'n' is uninitialized when used here
      [-Wuninitialized]
        int t[n], p[m], x[m];
              ^
50.cpp:7:7: note: initialize the variable 'n' to silence this warning
        int n, m;
             ^
              = 0
2 warnings generated.
asanomasakinoMacBook-Pro:b asanomaki$ vim 50.cpp
asanomasakinoMacBook-Pro:b asanomaki$ g++ 50.cpp 
50.cpp:8:8: warning: variable 'n' is uninitialized when used here
      [-Wuninitialized]
        int t[n], p[m], x[m];
              ^
50.cpp:7:7: note: initialize the variable 'n' to silence this warning
        int n, m;
             ^
              = 0
50.cpp:8:14: warning: variable 'm' is uninitialized when used here
      [-Wuninitialized]
        int t[n], p[m], x[m];
                    ^
50.cpp:7:10: note: initialize the variable 'm' to silence this warning
        int n, m;
                ^
                 = 0
2 warnings generated.
asanomasakinoMacBook-Pro:b asanomaki$ vim 50.cpp
asanomasakinoMacBook-Pro:b asanomaki$ g++ 50.cpp 
asanomasakinoMacBook-Pro:b asanomaki$ ./a.out 
3
2 1 4
2
1 1
2 3
6
8
asanomasakinoMacBook-Pro:b asanomaki$ vim 50.cpp
asanomasakinoMacBook-Pro:b asanomaki$ g++ 50.cpp 
asanomasakinoMacBook-Pro:b asanomaki$ ./a.out 
3
2 1 4
2 
1 1
2 3
6
8
asanomasakinoMacBook-Pro:b asanomaki$ vim 50.cpp
asanomasakinoMacBook-Pro:b asanomaki$ g++ 50.cpp 
asanomasakinoMacBook-Pro:b asanomaki$ ./a.out 
3
2 1 4
2
1 1
2 3
6
9
asanomasakinoMacBook-Pro:b asanomaki$ ./a.out 
5
7 2 3 8 5
3
4 2
1 7
4 13
19
25
30
asanomasakinoMacBook-Pro:b asanomaki$ vim 50.cpp

    cin >> n;
    int t[n];
    for (int i = 0; i < n; i++) {
        cin >> t[i];
    }   
    cin >> m;
    int p[m], x[m];
    for (int j = 0; j < m; j++) {
        cin >> p[j] >> x[j];
    }   
    int sum = 0;
    for (int k = 0; k < m; k++) {
        sum = 0;
        int pre = t[p[k] - 1]; 
        t[p[k] - 1] = x[k];
        for (int l = 0; l < n; l++) {
          sum += t[l];
        }
        t[p[k] - 1] = pre;
        cout << sum << endl;
    }
}




Compiler output:
a.cc:1:1: error: 'Last' does not name a type
    1 | Last login: Thu Oct 18 20:56:45 on console
      | ^~~~
a.cc:19:21: error: expected unqualified-id before '^' token
   19 |                     ^
      |                     ^
a.cc:22:17: error: expected unqualified-id before '^' token
   22 |                 ^
      |                 ^
a.cc:27:15: error: expected unqualified-id before '^' token
   27 |               ^
      |               ^
a.cc:30:14: error: expected unqualified-id before '^' token
   30 |              ^
      |              ^
a.cc:38:15: error: expected unqualified-id before '^' token
   38 |               ^
      |               ^
a.cc:41:14: error: expected unqualified-id before '^' token
   41 |              ^
      |              ^
a.cc:46:21: error: expected unqualified-id before '^' token
   46 |                     ^
      |                     ^
a.cc:49:17: error: expected unqualified-id before '^' token
   49 |                 ^
      |                 ^
a.cc:95:11: error: 'n' was not declared in this scope
   95 |     int t[n];
      |           ^
a.cc:96:5: error: expected unqualified-id before 'for'
   96 |     for (int i = 0; i < n; i++) {
      |     ^~~
a.cc:96:21: error: 'i' does not name a type
   96 |     for (int i = 0; i < n; i++) {
      |                     ^
a.cc:96:28: error: 'i' does not name a type
   96 |     for (int i = 0; i < n; i++) {
      |                            ^
a.cc:99:5: error: 'cin' does not name a type
   99 |     cin >> m;
      |     ^~~
a.cc:100:11: error: 'm' was not declared in this scope
  100 |     int p[m], x[m];
      |           ^
a.cc:100:17: error: 'm' was not declared in this scope
  100 |     int p[m], x[m];
      |                 ^
a.cc:101:5: error: expected unqualified-id before 'for'
  101 |     for (int j = 0; j < m; j++) {
      |     ^~~
a.cc:101:21: error: 'j' does not name a type
  101 |     for (int j = 0; j < m; j++) {
      |                     ^
a.cc:101:28: error: 'j' does not name a type
  101 |     for (int j = 0; j < m; j++) {
      |                            ^
a.cc:105:5: error: expected unqualified-id before 'for'
  105 |     for (int k = 0; k < m; k++) {
      |     ^~~
a.cc:105:21: error: 'k' does not name a type
  105 |     for (int k = 0; k < m; k++) {
      |                     ^
a.cc:105:28: error: 'k' does not name a type
  105 |     for (int k = 0; k < m; k++) {
      |                            ^
a.cc:115:1: error: expected declaration before '}' token
  115 | }
      | ^