Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include <iostream>
- #include <stdio.h>
- //using namespace std;
- int main() {
- int size, count1 = 0, count2 = 0; // çàä¸ì ðàçìåð ìàññèâà size, ïåðâûé è âòîðîé ñ÷¸ò÷èêè
- scanf("%d", &size); // ââîäèì ðàçìåð ìàññèâà
- int s[size]; // çàäà¸ì ìàññèâ
- for(int i = 0; i < size; i++) {
- scanf("%d", &s[i]); // öèêë íà çàïîëíåíèå ìàññèâà ÷èñëàì (þçåðîì)
- }
- for (int i = 1; i < size; i++) { // âûïîëíÿåì ïåðåáîð ìàññèâà (ïîñëåäîâàòåëüíî)
- if(s[i] >= s[i-1]) { // åñëè ÷èñëî áîëüøå ëèáî ðàâíî ïðåäûäóùåìó, äîáàâëÿåì åäèíèöó ê ñ÷¸ò÷èêó1
- count1++;
- }
- if(s[i] <= s[i-1]) { // åñëè ÷èñëî ìåíüøå ëèáî ðàâíî ïðåäûäóùåìó, äîáàâëÿåì åäèíèöó ê ñ÷¸ò÷èêó2
- count2++;
- }
- }
- if(count1 == size-1 && count2 == size-1) { // ñìîòðèì: åñëè çíà÷åíèå ñ÷¸ò÷èêà1 è ñ÷¸ò÷èêà2 ðàâíî size - 1,
- printf("vse ravni"); // òî ïîñëåäîâàòåëüíîñòü ñîñòîèò èç ðàâíûõ ÷èñåë
- }
- else if(count1 == size-1) { // èíà÷å, åñëè òîëüêî ñ÷¸ò÷èê1 ðàâåí size - 1
- printf("vozrastaet"); // òî ïîcëåäîâàòåëüíîñòü âîçðàñòàþùàÿ
- }
- else if(count2 == size-1) { // èíà÷å, åñëè òîëüêî ñ÷¸ò÷èê2 ðàâåí size - 1
- printf("ybivaet"); // òî ïîcëåäîâàòåëüíîñòü óáûâàþùàÿ
- }
- else{
- printf("neuporydacheno"); // åñëè íè îäíî èç óñëîâèé íå âûïîëíÿåòñÿ, òî ïîñëåäîâàòåëüíîñòü íåóïîðÿäî÷åíà
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement