cses

solution to cses exercise problems
git clone git://git.superpozycja.net/cses
Log | Files | Refs | README

commit 58b9272c56c653898c6080f733b1add6e9263f1e
parent a497a16a5e26af7825ff2b82c0cea76d931d7737
Author: superpozycja <anna@superpozycja.net>
Date:   Wed, 23 Oct 2024 21:09:15 +0200

solve missing number

Diffstat:
Aintro/missing_number.cpp | 25+++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)

diff --git a/intro/missing_number.cpp b/intro/missing_number.cpp @@ -0,0 +1,25 @@ +#include <bits/stdc++.h> + +using namespace std; + +void solve() +{ + int n; + cin >> n; + int a[n] = {0}; + for (int i = 0; i < n-1; i++) { + int t; + cin >> t; + a[t-1] = 1; + } + for (int i = 0; i < n; i++) { + if (a[i] == 0) + cout << i+1 << "\n"; + } + +} + +int main() +{ + solve(); +}