#include <iostream>
using namespace std;
const int N = 10;
int a[N];
void insert (int x)
{
int k = 0;
while (k < N && x > a[k])
k++;
// x umistit do a[k]
// k == N znamena, ze jsme nenasli vhodne misto
if (k < N)
{
for (int i = N-1; i>k; i--)
a[i] = a[i-1];
a[k] = x;
}
}
int main()
{
for (int j = 0; j<N; j++)
a[j] = 999;
insert (1);
insert (10);
insert (7);
insert (1000);
for (int j = 0; j<N; j++)
cout << a[j] << " ";
return 0;
}
#include <iostream>
using namespace std;
const string text = "nejaka posloupnost slov ";
int pos = 0;
int pocet ()
{
int v = 0;
int n = text.length();
while (text [pos] != ' ')
{
v++;
pos++;
if (pos >= n) pos = 0;
}
pos++;
if (pos >= n) pos = 0;
return v;
}
int main ()
{
cout << pocet () << endl;
cout << pocet () << endl;
cout << pocet () << endl;
cout << pocet () << endl;
cout << pocet () << endl;
cout << pocet () << endl;
cout << pocet () << endl;
cout << pocet () << endl;
cout << pocet () << endl;
}