pbinfo problema 1320
Răspunsuri la întrebare
Răspuns:
#include<iostream>
#include <fstream>
using namespace std;
int main()
{
int n, v[1009],k=-1 ;
cin>>n;
for (int i=1; i<=n; i++)
cin>>v[i];
int i=1;
while (i<n && v[i]==v[i+1])
i++;
if (i==n)
k=0;
else
{
i=1;
while (i<n && v[i]<=v[i+1])
i++;
if (i==n)
k=3;
i=1;
while (i<n && v[i]>=v[i+1])
i++;
if (i==n)
k=4;
i=1;
if(k==3||k==4)
{
int kk=0;
while (i<n)
{
if(v[i]==v[i+1])
kk++;
i++;
}
if(kk)
{
if(k==3)
k=1;
else
k=2;
}
}
}
switch (k)
{
case 0: cout<<"sir constant"; break;
case 1: cout<<"sir crescator"; break;
case 2: cout<<"sir descrescator"; break;
case 3: cout<<"sir strict crescator"; break;
case 4: cout<<"sir strict descrescator"; break;
default: cout<<"sir neordonat";
}
return 0;
}
Explicație: