267
社区成员
发帖
与我相关
我的任务
分享
好家伙题都看不懂
#include<iostream>
#include<string>
using namespace std;
int main()
{
double c1,c2;
cin>>c1>>c2;
double c=c2-c1;
double c0=c/100;
string s1=to_string(c0);
int pos=s1.find(".");
int a=s1[pos+1]-'0';
int res;
if(a>=5)
{
res=c0;
res+=1;
}
else if(a<5)
{
res=c0;
}
int h=res/3600;
int m=(res-h*3600)/60;
int s=res%60;
if(h<10)
{
cout<<"0";
}
cout<<h<<":";
if(m<10)
{
cout<<"0";
}
cout<<m<<":";
if(s<10)
{
cout<<"0";
}
cout<<s<<endl;
system("pause");
return 0;
}
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
vector<int> v1(33,0);
for(int i=1;i<33;i++)
{
v1[i]=2*i*i+4*i+1;
}
int num;
string s;
cin>>num>>s;
int m;
for(int i=1;i<33;i++)
{
if(num>=v1[i]&&num<v1[i+1])
{
m=i;
break;
}
}
if(num<7)
{
cout<<s<<endl;
}
else{
for(int i=m;i>=0;i--)
{
for(int j=0;j<m-i;j++)
{
cout<<" ";
}
for(int q=0;q<(2*i+1);q++)
{
cout<<s;
}
cout<<endl;
}
for(int i=1;i<=m;i++)
{
for(int j=0;j<m-i;j++)
{
cout<<" ";
}
for(int q=0;q<(2*i+1);q++)
{
cout<<s;
}
cout<<endl;
}
}
if(num<7)
{
cout<<num-1<<endl;
}
else
{
cout<<num-v1[m]<<endl;
}
system("pause");
return 0;
}
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
struct People{
string name;
int year;
int month;
int day;
};
bool cmp_age(const People &x, const People &y) {
if(x.year==y.year)
{
if(x.month==y.month)
{
return(x.day>y.day);
}
return(x.month>y.month);
}
return(x.year>y.year);
}
int main()
{
int n;
cin>>n;
int m0=n;
vector<int> v1(n,0);
set<int> s1;
for(int i=0;i<n;i++)
{
v1[i]=i;
}
struct People p1[n];
for(int i=0;i<n;i++)
{
cin>>p1[i].name;
string s11;
cin>>s11;
string y(s11,0,4);
string m(s11,5,2);
string d(s11,8,2);
p1[i].year=stoi(y);
p1[i].month=stoi(m);
p1[i].day=stoi(d);
if(p1[i].year>2014||p1[i].year<1814)
{
m0-=1;
s1.insert(i);
}
else if(p1[i].year==2014)
{
if(p1[i].month>9)
{
m0-=1;
s1.insert(i);
}
else if(p1[i].month==9&&p1[i].day>6)
{
m0-=1;
s1.insert(i);
}
}
else if(p1[i].year==1814)
{
if(p1[i].month<9)
{
m0-=1;
s1.insert(i);
}
else if(p1[i].month==9&&p1[i].day<6)
{
m0-=1;
s1.insert(i);
}
}
}
struct People p2[m0];
int j=0;
for(int i=0;i<n;i++)
{
if(s1.count(i)==0)
{
p2[j].name=p1[i].name;
p2[j].day=p1[i].day;
p2[j].year=p1[i].year;
p2[j].month=p1[i].month;
j++;
}
}
sort(p2,p2+m0,cmp_age);
if(m0!=0)
{
cout<<m0<<" "<<p2[m0-1].name<<" "<<p2[0].name<<endl;
}
else if(m0==0)
{
cout<<0<<endl;
}
system("pause");
return 0;
}
#include<iostream>
#include<string>
#include<set>
#include<vector>
#include<cctype>
using namespace std;
int main()
{
string s1,s2;
cin>>s1>>s2;
vector<char> v1;
set<char> s0;
for(int i=0;i<s1.size();i++)
{
for(int j=0;j<s2.size();j++)
{
if(s1[i]==s2[j])
{
break;
}
if(s1[i]!=s2[j]&&j==s2.size()-1)
{
if(islower(s1[i]))
{
v1.push_back(toupper(s1[i]));
continue;
}
v1.push_back(s1[i]);
}
}
}
for(int i=0;i<v1.size();i++)
{
if(s0.count(v1[i])==0)
{
cout<<v1[i];
s0.insert(v1[i]);
}
}
system("pause");
return 0;
}