by
36 7

Codingame - Temperatures - C++

Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/592283/Codingame---Temperatures---C--?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; /** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ int main() { int N,c; // the number of temperatures to analyse scanf("%d", &N); int number[N],ptemps,i=0,FLAG=0,mark; for(i=0;i<N;i++){ scanf("%d",&number[i]); } sort(number,number+N); for(i=0;i<N;i++){ if(number[i]>0)FLAG++; if(FLAG==1)mark=i; } if(N==0)printf("0"); else if(-1*number[mark-1]<number[mark])printf("%d",number[mark-1]); else printf("%d",number[mark]); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus