제출 #826356

#제출 시각아이디문제언어결과실행 시간메모리
826356KnightAddk (eJOI21_addk)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> using namespace std; int main() { int N, K, l, r, m, S; int *A; cin >> N >> K; A = new int[N]; int Temp; for(int i = N;i>0;i--){ cin >> Temp; A[N-i] = Temp; } int Q; cin >> Q; int *permList; permList = new int[K]; int extraTemp; for(int t = Q;t>0;t--){ int type; cin >> type; switch (type){ case 1: if(K!=1){ for(int i=0;i<K;i++){ cin >> Temp; permList[i] = Temp-1; } Temp = A[permList[0]]; for(int i=K-1;i>=0;i--){9 extraTemp = Temp; Temp = A[permList[i]]; A[permList[i]] = extraTemp; } }else{ cin >> Temp; } /*for(int i = 0;i<N;i++){ cout << A[i] << ' ';8 } cout << '\n';*/ break; case 2: cin >> l >> r >> m; //cout << l << ' ' << r << '\n'; S = 0; for(int i=l-1;i<r;i++){ int a=i-l+2; int c=r-i; if (a <= m && a <= c) S+=A[i]*a; else if (m <= a && m <= c) S+=A[i]*m; else S+=A[i]*c; //cout << S << '\n'; } cout << S << endl; } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:30:42: error: expected ';' before 'extraTemp'
   30 |                 for(int i=K-1;i>=0;i--){9
      |                                          ^
      |                                          ;
   31 |                     extraTemp = Temp;
      |                     ~~~~~~~~~             
Main.cpp:30:41: warning: statement has no effect [-Wunused-value]
   30 |                 for(int i=K-1;i>=0;i--){9
      |                                         ^