Find the number of spectators standing in the stadium at time t | CPP program to find number of spectators standing at a time ; If the time is less than k then we can print directly t time . ; If the time is n then k spectators are standing . ; Otherwise we calculate the spectators standing . ; Driver code ; Stores the value of n , k and t t is time n & k is the number of specators
#include <bits/stdc++.h> NEW_LINE using namespace std ; void result ( long long n , long long k , long long t ) { if ( t <= k ) cout << t ; else if ( t <= n ) cout << k ; else { long long temp = t - n ; temp = k - temp ; cout << temp ; } } int main ( ) { long long n , k , t ; n = 10 ; k = 5 ; t = 12 ; result ( n , k , t ) ; return 0 ; }