Дана структура struct time { int hour; int min; int sec ;}; Пользуясь таким структурным типом, составить программу, определяющуу предшествует ли время t1 времени t2(в пределах суток). пользуясь c#
var s : string[50]; i, j, k : word; f : boolean; function isSpace(ch : char) : boolean; begin isSpace := false; if ch = ' ' then isSpace := true; end; begin f := false; repeat j := 0; writeln('введите строку, состоящую из 2 слов'); readln(s); for i := 1 to length(s) do if isSpace(s[i]) then begin inc(j); k := i; end; if j =1 then f := true; until f; write(copy(s, k + 1, length(s)), ' ', copy(s, 1, k - 1)); end. недавно такую писала :)
using System;
namespace ConsoleApp1
{
struct time
{
public int hour;
public int min;
public int sec;
};
class Program
{
static void Main(string[] args)
{
time t1; t1.hour = 18; t1.min = 45; t1.sec = 23;
time t2; t2.hour = 18; t2.min = 45; t2.sec = 24;
if (t1.hour < t2.hour) Console.WriteLine("Время t1 предшествует t2");
else if ((t1.hour == t2.hour)&&(t1.min < t2.min)) Console.WriteLine("Время t1 предшествует t2");
else if ((t1.hour == t2.hour) && (t1.min == t2.min) && (t1.sec < t2.sec)) Console.WriteLine("Время t1 предшествует t2");
else Console.WriteLine("Время t1 не предшествует t2");
}
}
}