Ultimate monotonous junction sequence

xiaoxiao2021-03-05  46

First, the version of the C language:

#include main () {Int a [11], s [11], m [11]; int I, j, max;

For (i = 1; i <= 10; i ) {printf ("INPUT NUMBER A [% D]: / N", I); Scanf ("% D", & A [I]); M [i] = 1; s [i] = -1;}

M [1] = 1;

For (i = 1; i <= 10; i ) for (j = 1; j m [i]) {M [i] = m [j] 1; s [i] = j;}

MAX = 1; for (i = 1; i <= 10; i ) // printf ("% d / t", m [i]); if (m [i]> m [max]) max = i; i = max; // printf ("% d / n", i); while (s [i]! = -1) {printf ("% d / t", a [i]); i = s [i ];} Printf ("% d", a [i]);

Then it is Python version:

A = [0] * 11 s = [0] * 11 m = [0] * 11 Print A Print S Print M for i in Range (1, 11): a [i] = int (Raw_Input ("INPUT NUMBER A [% D]: / n "% (i)))) M [i] = 1 s [i] = -1 m [1] = 1 Print A Print S Print M for I in Range (1,11): for J in Range (1, i): IF A [J] <= a [i] and m [j] 1> m [i]: M [i] = M [J] 1 s [i] = j max =

1 for i in range (1, 11): IF m [i]> m [max]: max = i = max while s [i]! = -1: Print a [i] i = s [i] print a [i]

转载请注明原文地址:https://www.9cbs.com/read-32988.html

New Post(0)