csansoon

P6.14 P89851 Which is missing?

Nov 7th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n,x;
  6.     while (cin>>n) {
  7.         int totalx=0,totaln=n;
  8.         for (int i=n-1;i>0;i--) {
  9.             cin>>x;
  10.             totalx=totalx+x;
  11.             totaln=totaln+i;
  12.         }
  13.         cout<<totaln-totalx<<endl;
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment