前言:代码仅供参考,不是最优代码,存在问题的话,请指正,还有就是题目顺序搞忘了,名字只大体记得。。。
时间A+B
大意:给你两个时间相加,简单模拟时间的运算
#include<bits/stdc++.h>
using namespace std;
typedef struct time{
int h;
int m;
int s;
}ti;
int main(){
ti t1, t2;
while(cin>>t1.h>>t1.m>>t1.s>>t2.h>>t2.m>>t2.s){
ti t3;
t3.h=0;t3.m=0;t3.s=0;
t3.s=t1.s+t2.s;
if(t3.s>=60){
t3.m+=1;t3.s-=60;
}
t3.m=t3.m+t1.m+t2.m;
if(t3.m>=60){
t3.h+=1;t3.m-=60;
}
t3.h=t1.h+t2.h+t3.h;
if(t3.h<10){
cout<<"0";
}
cout<<t3.h<<":";
if(t3.m<10){
cout<<"0";
}
cout<<t3.m<<":";
if(t3.s<10){
cout<<"0";
}
cout<<t3.s<<"\n";
}
}
去重数
大意 去除相同的数。。
因为是在100内,所以直接开个数组标记一下就行了,不用多想
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
while(cin>>n){
int a[200

本文精选了多种算法题目的解决方案,包括时间计算、去重、二进制转换、数学规律识别、邮件阅读策略、细菌繁殖模拟、洞穴封堵策略、蠕虫逃脱分析以及重复字符查找等,展示了丰富的算法应用实例。
最低0.47元/天 解锁文章
2768

被折叠的 条评论
为什么被折叠?



