
#include <iostream>
#include <vector>
using namespace std;
void bubbleSort(vector<int> &a_){
vector<int> t;
int n = a_.size();
for(int i = 0; i < n; i++)
for(int j = 0; j < n - i - 1; j++)
if(a_[j] > a_[j + 1])
swap(a_[j], a_[j + 1]);
for(auto &i: a_) if(i & 1) t.push_back(i);
a_ = t;
}
void solve(){
vector<int> a = {2, 10, 5, 3, 11, 9, 12};
bubbleSort(a);
cout << "a = {";
for(int i = 0; i < a.size() - 1; i++)
cout << a[i] << ", ";
cout << a.back() << "}";
}
int main(){
solve();
}
import random
def GenEx(count):
signs = ['+', '-', '*', '/']
for _ in range(count):
fn = random.randint(-20, 20)
sn = random.randint(-20, 20)
ex = '{0} {1} {2}'.format(fn, random.choice(signs), sn)
yield (ex + ' = ?', eval(ex))
IsGameRun = True
while IsGameRun:
TrueAnsws = 0
for ex, check in GenEx(2):
print(ex)
resvAnsw = float(input())
if resvAnsw == check: TrueAnsws += 1;
IsRetry = input('You correctly solved '+str(TrueAnsws)+' examples. Do you want to try again? Y/N \n')
if IsRetry == 'Y': IsGameRun = True
else: IsGameRun = False
Объяснение: