Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ChuvSU yandex.contest 20!8
- //Matvey&Volodya 21-18
- //Compiler == GNU c++11 4.9
- //1
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, sum=0;
- cin >> n;
- int a[n];
- for (int i=0;i<n;i++)
- cin >> a[i];
- for (int i=0;i<n;i++)
- sum+=a[i];
- cout<<sum;
- }
- //2
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,temp=0,len=0,m=0,max_len=0;
- cin >> n;
- int a[n];
- for (int i=0; i<n; i++)
- cin >> a[i];
- for (int i=1; i<n; i++)
- {
- if(a[i]<a[i-1])
- len++;
- else{
- if(len>max_len)
- {
- max_len=len;
- m=temp;
- }
- len=0;
- temp=i;
- }
- }
- if(max_len>len)
- {
- len=max_len;
- temp=m;
- }
- max_len=0;
- for(int i=temp; i<=temp+len; i++) max_len++;
- cout << max_len;
- }
- //5
- #include <iostream>
- using namespace std;
- int main()
- {
- int N;
- cin >> N;
- int a[N];
- for (int i=0;i<N;i++)
- cin >> a[i];
- for (int i=0;i<N;i++)
- if ((a[i]%2)!=0) cout << a[i] << " ";
- for (int i = 0; i < N; i++)
- if ((a[i]%2)==0) cout << a[i] << " ";
- return 0;
- }
- //6
- #include <iostream>
- using namespace std;
- int main()
- {
- int N,i;
- cin >> N;
- int a[N];
- for (int i=0;i<N;i++)
- cin >> a[i];
- for (int i=0;i<N;i++){
- if ((a[i]%2)==0) cout << a[i] << " ";}
- for (int i = 0; i < N; i++){
- if ((a[i]%2)!=0) cout << a[i] << " ";}
- return 0;
- }
- //7
- #include <iostream>
- using namespace std;
- int main()
- {
- float AvgSum,Sum=0,Count=0;
- int N;
- cin >> N;
- int a[N];
- for (int i = 0; i < N; i++)
- cin >> a[i];
- for (int i = 0; i < N; i++)
- {
- if (a[i]>0)
- {
- Sum+=a[i];
- Count++;
- }
- }
- if (Count==0)
- AvgSum=0;
- else AvgSum=Sum/Count;
- for (int i = 0; i < N; i++)
- {
- if (a[i]<=AvgSum)
- cout << a[i] << " ";
- }
- }
- //8
- #include <iostream>
- using namespace std;
- int main()
- {
- int N,Count=0;
- int m;
- cin >> N;
- int a[N];
- for (int i=0;i<N;i++)
- cin >> a[i];
- cin >> m;
- for (int i=0;i<N;i++)
- if (a[i]==m*m) {cout << a[i] << " "; Count++;}
- if (Count==0) cout << "NO";
- return 0;
- }
- //9
- #include <iostream>
- using namespace std;
- int main()
- {
- int N;
- cin >> N;
- int a[N];
- for (int i = 0; i < N; ++i)
- cin >> a[i];
- for (int i = 0; i < N; ++i)
- {
- if (a[i]!=0) cout << a[i] << " ";
- }
- return 0;
- }
- //10
- #include <iostream>
- using namespace std;
- int main()
- {
- int N;
- cin >> N;
- int a[N];
- for (int i = 0; i < N; ++i)
- cin >> a[i];
- for (int i = N; i >= 1; --i)
- for (int j = 0; j < i; ++j)
- {
- if(a[j]==0)
- {
- int temp = a[j];
- a[j] = a[j-1];
- a[j-1] = temp;
- }
- }
- for (int i = 0; i < N; ++i)
- cout << a[i] << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement