求助SSCANF
  • 板块灌水区
  • 楼主alpharchmage
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/8/24 15:32
  • 上次更新2023/11/3 01:30:48
查看原帖
求助SSCANF
411141
alpharchmage楼主2023/8/24 15:32
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n = 0;
int times[200001];
bool cmp(int x,int y)
{
	return x < y;
}
struct Time{
	int y;
	int m;
	int d;
	int h;
	int c;
	string tmp;
}start,goal;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin >> n;
	for(int i = 1;i <= n;++ i)
		cin >> times[i];
	sort(times + 1,times + n + 1,cmp);
	cin >> start.tmp;
	cin >> goal.tmp;
	sscanf(start.tmp,"%d-%d-%d-%d:%d",&start.y,&start.m,&start.d,&start.h,&start.c);
	sscanf(goal.tmp,"%d-%d-%d-%d:%d",&goal.y,&goal.m,&goal.d,&goal.h,&goal.c);
	return 0;
} 

还没写完,但是CE了,

29 80 C:\Users\Administrator\Documents\P1167.cpp [Error] cannot convert 'std::string {aka std::basic_string}' to 'const char*' for argument '1' to 'int sscanf(const char*, const char*, ...)'

2023/8/24 15:32
加载中...