#include <iostream>
using namespace std;
int main()
{
const int time = 86400;
int a;
cout << "Enter the time in seconds elapsed since the beginning of the day" << endl;
cin >> a;
int hh = a % time / 3600;
int mm = a / 60 % 60;
int ss = a % 60;
int endhh, endmm, endss;
int tmp = hh * 3600 + mm * 60 + ss;
tmp = time - tmp;
endhh = tmp / 3600;
endmm = tmp / 60 - endhh * 60;
endss = tmp - endmm * 60 - endhh * 3600;
cout << "Now is: " << hh << " hh: " << mm << " mm: " << ss << " ss" << endl;
cout << "before the midnight: " << endhh << " hh: " << endmm << " mm: " << endss << " ss" << endl;
return 0;
}
Объяснение:
#include <iostream>
using namespace std;
int main()
{
const int time = 86400;
int a;
cout << "Enter the time in seconds elapsed since the beginning of the day" << endl;
cin >> a;
int hh = a % time / 3600;
int mm = a / 60 % 60;
int ss = a % 60;
int endhh, endmm, endss;
int tmp = hh * 3600 + mm * 60 + ss;
tmp = time - tmp;
endhh = tmp / 3600;
endmm = tmp / 60 - endhh * 60;
endss = tmp - endmm * 60 - endhh * 3600;
cout << "Now is: " << hh << " hh: " << mm << " mm: " << ss << " ss" << endl;
cout << "before the midnight: " << endhh << " hh: " << endmm << " mm: " << endss << " ss" << endl;
return 0;
}
Объяснение:
Поделитесь своими знаниями, ответьте на вопрос:
Дан массив из n элементов. вывести на экран все элементы которые делятся на 2, 3 и не делятся на 4. n=10
begin
var n:=ReadlnInteger('n =');
var a:=ArrRandom(n,0,500);
a.Println;
Writeln('Выбранные элементы:');
a.Select(x->x).Where(x->(x mod 2=0)and(x mod 3=0)and(x mod 4<>0)).Println;
end.
Пример:
n = 10
105 18 117 360 83 72 347 498 354 34
Выбранные элементы:
18 498 354
2.
const n=10;
var a: array[1..n] of integer;
i : integer;
begin
writeln('Исходный массив:');
for i:=1 to n do begin
write('a[',i,']=');
readln(a[i]);
end;
writeln;
for i:=1 to n do
if (a[i] mod 2=0)and(a[i] mod 3=0)and(a[i] mod 4<>0)
then write(a[i],' ');
end.
Пример:
Исходный массив:
a[1]=105
a[2]=18
a[3]=117
a[4]=360
a[5]=83
a[6]=72
a[7]=347
a[8]=498
a[9]=354
a[10]=34
18 498 354