- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 50
#define K 6
main()
{int i,j,n,error,max,imax,min=0,imin=0;
int a[N][K],b[N][K];
long c[N],r;
do
{error=0;
printf("Vvedite kol-vo raznih dat: ");
scanf("%d",&n);
if(n<1 || n>N)
{printf("\nVi vveli kol-vo elementov massiva men'she 2 ili bol'she 50!\nPovtorite vvod!\n\n");
error=1;
}
}
while (error);
printf("\nDati v formate GG MM DD cc mm ss:\n");
for(i=0;i<n;i++)
{do a[i][0]=rand()%2008; while(a[i][0]<1970);
do a[i][1]=rand()%13; while(a[i][1]<1);
do a[i][2]=rand()%32; while(a[i][2]<1);
a[i][3]=rand()%24;
a[i][4]=rand()%60;
a[i][5]=rand()%60;
printf("\nData %d:",i+1);
for (j=0;j<K;j++)
printf(" %.2d",a[i][j]);
}
max=0;
for(i=0;i<n;i++)
if (a[i][0]>max)
{
max=a[i][0];
imax=i;
}
min=a[0][0];
for(i=0;i<n;i++)
if (a[i][0]<min)
{
min=a[i][0];
imin=i;
}
for(i=0;i<2;i++)
{
for(j=0;j<K;j++)
{
b[i][j]=a[imax][j];
}
imax=imin;
}
for(i=0;i<2;i++)
{
printf("\n");
for(j=0;j<K;j++)
printf(" b[%d,%d]=%d",i,j,b[i][j]);
}
for(i=0;i<2;++i)
{
c[i]=(b[i][0]-1971)*31536000;
c[i]+=b[i][2]*86400;
c[i]+=b[i][3]*3600;
c[i]+=b[i][4]*60;
c[i]+=b[i][5]-86400;
c[i]+=((b[i][0]-69)/4)*86400;
if(b[i][1]>12)
c[i]+=31*86400;
if(b[i][1]>11)
c[i]+=30*86400;
if(b[i][1]>10)
c[i]+=31*86400;
if(b[i][1]>9)
c[i]+=30*86400;
if(b[i][1]>8)
c[i]+=31*86400;
if(b[i][1]>7)
c[i]+=31*86400;
if(b[i][1]>6)
c[i]+=30*86400;
if(b[i][1]>5)
c[i]+=31*86400;
if(b[i][1]>4)
c[i]+=30*86400;
if(b[i][1]>3)
c[i]+=31*86400;
if(b[i][1]>2)
c[i]+=28*86400;
if(b[i][1]>1)
c[i]+=31*86400;
if(((b[i][1]==2 && b[i][2]==29) || b[i][1]>2) && b[i][1]>1 && b[i][0]%4==0 && b[i][0]%100!=0 || b[i][0]%400==0)
c[i]+=151936;
}
printf("\n\nDati v formate vremennoi metki UNIX:\n\n");
for(i=0;i<2;i++)
{printf("Data %d: %ld\n",i+1,c[i]);
}
r=c[0]-c[1];
guest 11.08.2009 13:38 # 0
guest 21.08.2009 14:18 # 0
guest 15.03.2010 23:25 # +1
guest8 09.04.2019 18:22 # −999
guest8 09.04.2019 18:23 # −999
guest8 09.04.2019 18:24 # −999
guest8 09.04.2019 18:26 # −999
guest8 09.04.2019 18:27 # −999
guest8 24.09.2019 22:34 # −999