Open maud99 opened 2 years ago
clock是关键字,换一个命名
using namespace std;
class cl { public: int hh,mm,ss; };
void timerange(cl c1,cl c2) { int hh,mm,ss; ss=c1.ss-c2.ss; if(ss<0) c1.mm=c1.mm-1; ss=(ss+60)%60; mm=c1.mm-c2.mm; if(mm<0) c1.hh=c1.hh-1; mm=(mm+60)%60; hh=c1.hh-c2.hh; printf("%02d:%02d:%02d",hh,mm,ss); }
int main() { cl c1,c2; scanf("%d:%d:%d",&c1.hh,&c1.mm,&c1.ss); scanf("%d:%d:%d",&c2.hh,&c2.mm,&c2.ss); if (c1.hh>c2.hh) { timerange(c1,c2); } else if (c1.hh<c2.hh) { timerange(c2,c1); } else if (c1.mm>c2.mm) { timerange(c1,c2); } else if (c1.mm<c2.mm) { timerange(c2,c1); } else if (c1.ss>c2.ss) { timerange(c1,c2); } else if (c1.ss<c2.ss) { timerange(c2,c1); } else { timerange(c1,c2); } system("pause"); return 0; }
换了命名依然报错TAT
代码:
include
using namespace std;
class clock { public: int hh,mm,ss; };
void timerange(clock c1,clock c2) { int hh,mm,ss; ss=c1.ss-c2.ss; if(ss<0) c1.mm=c1.mm-1; ss=(ss+60)%60; mm=c1.mm-c2.mm; if(mm<0) c1.hh=c1.hh-1; mm=(mm+60)%60; hh=c1.hh-c2.hh; printf("%02d:%02d:%02d",hh,mm,ss); }
int main() { clock c1,c2; scanf("%d:%d:%d",&c1.hh,&c1.mm,&c1.ss); scanf("%d:%d:%d",&c2.hh,&c2.mm,&c2.ss); if (c1.hh>c2.hh) { timerange(c1,c2); } else if (c1.hh<c2.hh) { timerange(c2,c1); } else if (c1.mm>c2.mm) { timerange(c1,c2); } else if (c1.mm<c2.mm) { timerange(c2,c1); } else if (c1.ss>c2.ss) { timerange(c1,c2); } else if (c1.ss<c2.ss) { timerange(c2,c1); } else { timerange(c1,c2); } system("pause"); return 0; } 在ice上过不了编译但vscode上没有问题,是什么缘故呀