文章
84
粉丝
408
获赞
33
访问
871.9k
输入采用scanf("%d:%d", &time.hour, &time.minute)会比较省事
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
typedef struct Node{
int hour;
int minute;
int endh;
int endm;
}node;
int main()
{
int N;
cin >> N;
int starth = 13, startm = 15;
vector<node> vtime;
for (int i = 0; i < N; i++) {
node time;
scanf("%d:%d", &time.hour, &time.minute);
int carry = 0;
time.endm = startm + time.minute;
if (time.endm >= 60) {
carry = 1;
time.endm -= 60;
}
time.endh = (starth + time.hour + carry) % 24;
vtime.push_back(time);
}
for (int i = 0; i < N; i++) {
cout << vtime[i].endh << ":" << vtime[i].endm << endl;
}
return 0;
}
登录后发布评论
#include<bits/stdc++.h>
using namespace std;
typedef struct Node{
int hour;
int minute;
int endh;
int endm;
}node;
int main()
{
int N;
cin>>N;
int starth=13,startm=15;
vector<node> vtime;
for(int i=0;i<N;i++)
{
node time;
scanf("%d:%d",&time.hour,&time.minute);
int carry=0;
time.endm=startm+time.minute;
if(time.endm>=60)
{
carry=1;
time.endm-=60;
}
time.endh=(starth+time.hour+carry)%24;
vtime.push_back(time);
}
for(int i=0;i<N;i++)
{
cout<<vtime[i].endh<<":"<<vtime[i].endm<<endl;
}
return 0;
}