L1-018 大笨钟(10分)

注意sscanf的用法。

#include <bits/stdc++.h>
using namespace std;
int main(){
	int xs,fz;
	string s;
	cin >> s;
	sscanf(s.c_str(),"%d:%d",&xs,&fz);
    if(xs>=0&&(xs<12)) printf("Only %s.  Too early to Dang.",s.c_str());
    if(xs==12&&fz==0) printf("Only %s.  Too early to Dang.",s.c_str());
    int hour = 0;
    if(fz==0){
    	hour=xs-12;
    	for(int i=0;i<hour;i++) printf("Dang");
	}else{
		hour=xs+1-12;
		for(int i=0;i<hour;i++) printf("Dang");
	}
	return 0;
}
posted @ 2024-03-08 18:07  YuKiCheng  阅读(7)  评论(0编辑  收藏  举报