#include<iostream> using namespace std; void speed(double a){ double v; v=(a-95859)/2; cout<<"汽车的车速为"<<v<<endl; } int main(){ int i,j; double s; int A[5]={0}; for(i=95860;i<100000;i++) { int t=i; for(j=0;j<5;j++) { A[j]=t%10; t/=10; } if(A[0]==A[4]&&A[1]==A[3]) { for(j=0;j<5;j++) { cout<<A[j]; } break; } } s=A[4]*10000+A[3]*1000+A[2]*100+A[1]*10+A[0]; speed(s); return 0; }
#include<iostream> #include<math.h> using namespace std; class clock{ private: int hour,minture,second; public: clock(){} clock(int a,int b,int c){ hour=a; minture=b; second=c; } ~clock(){} friend ostream & operator<<(ostream&out,clock&c){ out<<c.hour<<"."<<c.minture<<"."<<c.second<<endl; return out; } friend istream & operator>>(istream&in,clock&c){ in>>c.hour>>c.minture>>c.second; return in; } clock operator++(){ this->second++; if(this->second==60){ this->minture++; this->second=0; } if(this->minture==60){ this->hour++; this->minture=0; } if(hour==24){ this->hour=0; this->minture=0; this->second=0; } return *this; } clock operator--(int ){ clock old=*this; this->second--; return old; /*this->second=--this->second; return *this;*/ } }; int main(){ clock c1; cout<<"请输入时间"<<endl; cin>>c1; cout<<c1<<endl; cout<<++c1<<endl; cout<<c1--<<endl; }
标签:return,hour,clock,19,minture,int,second,2023 From: https://www.cnblogs.com/xuxingkai/p/17334734.html