package com.navikolus.timerExample;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Chronometer;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private Chronometer mChronometer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mChronometer = (Chronometer) findViewById(R.id.chronometer);
mChronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
@Override
public void onChronometerTick(Chronometer chronometer) {
long elapsedMillis = SystemClock.elapsedRealtime()
- mChronometer.getBase();
if (elapsedMillis > 5000) {
String strElapsedMillis = "Прошло больше 5 секунд";
Toast.makeText(getApplicationContext(),
strElapsedMillis, Toast.LENGTH_SHORT)
.show();
}
}
});
}
public void onStartClick(View view) {
mChronometer.setBase(SystemClock.elapsedRealtime());
mChronometer.start();
}
public void onStopClick(View view) {
mChronometer.stop();
}
public void onResetClick(View view) {
mChronometer.setBase(SystemClock.elapsedRealtime());
}
}
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void bubble_sort(int *a, int array_size) {
for (int i = 0; i < array_size - 1; i++) {
for (int j = 0; j < array_size - i - 1; j++) {
if (a[j] > a[j+1]) {
int save;
save = a[j];
a[j] = a[j + 1];
a[j + 1] = save;
}
}
}
}
int main() {
srand(time(0));
int a_s;
int b_s;
int answer;
cout << "Enter the size of the first array: ";
cin >> a_s;
cout << endl;
cout << "Thx. Now, the second array: ";
cin >> b_s;
if (((a_s + b_s) % 2) == 0) {
b_s = b_s + 1;
cout << "First and second sizes are even. We'll add 1 point to size of second array. ";
}
cout << endl;
cout << "===================================";
cout << endl;
cout << "Random values or input from keyboard? (1/2, yeap, i'm very lazy to use strcmp() :) ";
cin >> answer;
cout << "===================================";
cout << endl;
int *a = new int[a_s];
int *b = new int[b_s];
cout << "All values will be automatically sorted in ASC order!" << endl;
cout << "Warning! Don't type the same numbres! The middle values also will be counted!!" << endl;
cout << endl;
if (answer == 1) {
for (int i = 0; i < a_s; i++) {
a[i] = rand() % 10 + 1;
}
for (int i = 0; i < b_s; i++){
b[i] = rand() % 16 + 1;
}
}
else if(answer == 2) {
for (int i = 0; i < a_s; i++) {
cout << "a[" << i + 1 << "]: ";
cin >> a[i];
}
for (int i = 0; i < b_s; i++) {
cout << "b[" << i + 1 << "]: ";
cin >> b[i];
}
}
bubble_sort(a, a_s);
bubble_sort(b, b_s);
int counter1 = 0,
counter2 = 0,
counter3 = 0;
for (int counter = 0; counter < (a_s + b_s) / 2; counter++)
{
if (a[counter1] <= b[counter2]) {
counter3 = a[counter1];
counter1++;
}
else {
counter3 = b[counter2];
counter2++;
}
}
cout << counter3;
system("pause");
return 0;
}
<img ... onmouseover="a(getAttribute(id));">
function a (gotId) {
var id_gotId = document.getElementById(gotId); // пихаем DOM-обращение в переменную, дабы не засорять копипастом код
id_gotId.setAttribute("class", "animation"); // навесили на элемент класс с анимацией
id_gotId.setAttribute("onmouseover", " "); // исключаем возможность повторного наведения мыши во время анимации
setTimeout(function(){
id_gotId.setAttribute("class", " "); // убираем класс для возможности повторного применения анимации
id_gotId.setAttribute("onmouseover", "a(getAttribute('id'))"); // возвращаем onmouseover-ивент
}, 750); // время таймера
}
.animation{
animation: bounceInAnim .75s 1;
}
@keyframes bounceInAnim {
from, 20%, 40%, 60%, 80%, to {
-webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
}
10% {
-webkit-transform: scale3d(.3, .3, .3);
transform: scale3d(.3, .3, .3);
}
30% {
-webkit-transform: scale3d(1.1, 1.1, 1.1);
transform: scale3d(1.1, 1.1, 1.1);
}
40% {
-webkit-transform: scale3d(.9, .9, .9);
transform: scale3d(.9, .9, .9);
}
60% {
-webkit-transform: scale3d(1.03, 1.03, 1.03);
transform: scale3d(1.03, 1.03, 1.03);
}
80% {
-webkit-transform: scale3d(.97, .97, .97);
transform: scale3d(.97, .97, .97);
}
to {
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1);
}
}