Submission #238623

# Submission time Handle Problem Language Result Execution time Memory
238623 2020-06-12T08:14:52 Z Vankeca Datum (COCI20_datum) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
char day1[2], month1[2], year1[4], day2[2], month2[2], year2[4];
int d1,m1,y1;
///----------------------------------------------
void read()
{
	char dot;
	cin>>day1[0]>>day1[1];
	cin>>dot;
	cin>>month1[0]>>month1[1];
	cin>>dot;
	cin>>year1[0]>>year1[1]>>year1[2]>>year1[3];
}
///----------------------------------------------
void convert_st()
{
	d1=int(day1[0]-'0')*10+int(day1[1]-'0');
	m1=int(month1[0]-'0')*10+int(month1[1]-'0');
	y1=int(year1[0]-'0')*1000+int(year1[1]-'0')*100+int(year1[2]-'0')*10+int(year1[3]-'0');
}
///----------------------------------------------
void construct_date(int y)
{
	int i=3;
	while(y>=0 && i>=0)
	{
		year2[i]=char(y%10+'0');
		y/=10;
		i--;
	}
	day2[0]=year2[3]; day2[1]=year2[2];
	month2[0]=year2[1]; month2[1]=year2[0];
	//cout<<day2[0]<<day2[1]<<"."<<month2[0]<<month2[1]<<"."<<year2[0]<<year2[1]<<year2[2]<<year2[3]<<endl;
}
///----------------------------------------------
int convert_dec(int k)
{
	if(k==1)
	{
		return int(day2[0]-'0')*10+int(day2[1]-'0');
	}
	if(k==2)
	{
		return int(month2[0]-'0')*10+int(month2[1]-'0');
	}
	if(k==3)
	{
		return int(year2[0]-'0')*1000+int(year2[1]-'0')*100+int(year2[2]-'0')*10+int(year2[3]-'0');
	}
}
///----------------------------------------------
bool check()
{
	int d=convert_dec(1), m=convert_dec(2), y=convert_dec(3);
	if(d==0 || m==0)return false;
	if(d>31 || m>12)return false;
	if(d==31 && m==2 || m==4 || m==6 || m==9 || m==11)return false;
	if(d==29 && m==2)
	{
		if(y%4!=0)return false;
	}
	if(d<=d1 && m<=m1 && y==y1)return false;
	return true;
}
///----------------------------------------------
void solve()
{
	convert_st();
	construct_date(y1);
	int i=y1;
	while(check()==false)
	{
		i++;
		construct_date(i);
	}
	cout<<day2[0]<<day2[1]<<"."<<month2[0]<<month2[1]<<"."<<year2[0]<<year2[1]<<year2[2]<<year2[3]<<endl;
}
///----------------------------------------------
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin>>n;
	while(n--)
	{
		read();
		solve();
	}
	
	return 0;
}

Compilation message

datum.cpp:5:11: error: 'int y1' redeclared as different kind of symbol
 int d1,m1,y1;
           ^~
In file included from /usr/include/features.h:367:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533,
                 from /usr/include/c++/7/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from datum.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:251:1: note: previous declaration 'double y1(double)'
 __MATHCALL (y1,, (_Mdouble_));
 ^
datum.cpp: In function 'void convert_st()':
datum.cpp:21:87: error: assignment of function 'double y1(double)'
  y1=int(year1[0]-'0')*1000+int(year1[1]-'0')*100+int(year1[2]-'0')*10+int(year1[3]-'0');
                                                                                       ^
datum.cpp:21:87: error: cannot convert 'int' to 'double(double) throw ()' in assignment
datum.cpp: In function 'bool check()':
datum.cpp:59:11: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  if(d==31 && m==2 || m==4 || m==6 || m==9 || m==11)return false;
     ~~~~~~^~~~~~~
datum.cpp:64:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  if(d<=d1 && m<=m1 && y==y1)return false;
                          ^~
datum.cpp: In function 'void solve()':
datum.cpp:71:19: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
  construct_date(y1);
                   ^
datum.cpp:24:6: note:   initializing argument 1 of 'void construct_date(int)'
 void construct_date(int y)
      ^~~~~~~~~~~~~~
datum.cpp:72:8: error: invalid conversion from 'double (*)(double) throw ()' to 'int' [-fpermissive]
  int i=y1;
        ^~
datum.cpp: In function 'int convert_dec(int)':
datum.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^