杭电oj2000-2009c++

杭电2000

#include
#include
using namespace std;
int main()
{
     
	char ls[4];
	while(cin>>ls[0]>>ls[1]>>ls[2])
	{
     
		sort(ls,ls+3);cout<<ls[0]<<" "<<ls[1]<<" "<<ls[2]<<endl;
	}
	
	return 0; 
}
杭电2000

```cpp
#include
using namespace std;
int main()
{
	char str[3],temp;
	while(cin>>str)
	{
		if(str[0]>str[1])
		{
			temp=str[0],str[0]=str[1],str[1]=temp;
		}
		if(str[0]>str[2])
		{
			temp=str[0],str[0]=str[2],str[2]=temp;
		}
		if(str[1]>str[2])
		{
			temp=str[1],str[1]=str[2],str[2]=temp;
		}
		cout<
杭电2001

```cpp
#include
#include 
#include
using namespace std;
int main()
{
	double x1,x2,y1,y2,x;
	while(cin>>x1>>y1>>x2>>y2)
	{
		x=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	    cout<

杭电2002

#include
#include//setiosflags(ios::fixed),头文件为:include 
#define pi 3.1415927
using namespace std;
int main()
{
     
	double v,r;
	while(cin>>r)
	{
     
		v=pi*r*r*r*4/3;
		cout<<setiosflags(ios::fixed)<<setprecision(3)<<v<<endl;//setprecision(n)与setiosflags(ios::fixed)合用,可以控制小数点右边的数字个数。
	}
	return 0;
 } 

杭电2003

#include
#include
using namespace std;
int main()
{
     
	double n;
	while(cin>>n)
	{
     
		if(n>0)
		{
     
			cout<<fixed<<setprecision(2)<<n<<endl;
		}
		else
			cout<<fixed<<setprecision(2)<<-n<<endl;
	}
	return 0;
}

杭电2004

#include
using namespace std;
int main()
{
     
	int a;
	while(cin>>a)
	{
     
		if(a>=90&&a<=100)
		{
     
			cout<<'A'<<endl;
		}
		else if(a>=80&&a<=89)
		{
     
			cout<<'B'<<endl;
		}
		else if(a>=70&&a<=79)
		{
     
			cout<<'C'<<endl;
		}
		else if(a>=60&&a<=69)
		{
     
			cout<<'D'<<endl;
		}
		else if(a>=0&&a<=59)
		{
     
			cout<<'E'<<endl;
		}
		else cout<<"Score is error!"<<endl;
	}
	return 0;
}

杭电2005

#include
using namespace std;
int main()
{
     
	int y,m,d,i,s;
	while(cin>>y)
	{
     
		s=0;
		int t1[12]={
     31,28,31,30,31,30,31,31,30,31,30,31};
		int t2[12]={
     31,29,31,30,31,30,31,31,30,31,30,31};
		cin.ignore();
		cin>>m;
		cin.ignore();
		cin>>d;
		if((y%400==0)||((y%100!=0)&&(y%4==0)))
		{
     
		for(i=0;i<m-1;i++)
		{
     
			s=s+t2[i];
		}
			s=s+d;
		}
		else
		{
     
			for(i=0;i<m-1;i++)
			{
     
			s=s+t1[i];
			}
			s=s+d;	
		}
		cout<<s<<endl;
	}
	return 0;
}
杭电2006

```cpp
#include
using namespace std;
int main()
{
	int n,m,sum;
	while(cin>>n)
	{
		sum=1;
		for(int i=0;i>m;
		if(m%2!=0)
		{
			sum=sum*m;
		}
 	    }
		cout<

杭电2007

#include
using namespace std;
int main()
{
     
	int n,m,x,y,i;
	while(cin>>m>>n)
	{
     
		x=0,y=0;
		if(m>n)//比较n m的大小。 
		{
     
			i=m,m=n,n=i;
		}
		for(;m<=n;m++)
		{
     
			if(m%2==0)
			{
     
				x=x+m*m;
			}
			else y=y+m*m*m;
		}
		cout<<x<<" "<<y<<endl;
	}
	return 0;
}

杭电2008

#include
using namespace std;
int main()
{
     
	int n;
	while(cin>>n)
	{
     
		if(n==0)
		{
     
			break;
		}
			double a=0,b=0,c=0,i=0,x;
			while(cin>>x)
			{
     
				i++;
			if(x<0)
				{
     
					a++;
				}
				if(x==0)
					{
     
						b++;
					}
					if(x>0)
						{
     
							c++;
						} 
						if(i==n)
							{
     
								break;
							}
			}
		cout<<a<<" "<<b<<" "<<c<<endl;
	}
	return 0;
}

杭电2009

```cpp
#include
using namespace std;
int main()
{
	int n;
	while(cin>>n)
	{
		if(n==0)
		{
			break;
		}
			double a=0,b=0,c=0,i=0,x;
			while(cin>>x)
			{
				i++;
			if(x<0)
				{
					a++;
				}
				if(x==0)
					{
						b++;
					}
					if(x>0)
						{
							c++;
						} 
						if(i==n)
							{
								break;
							}
			}
		cout<

你可能感兴趣的:(杭电oj2000-2009c++)