入门水题找找灵感,题就不贴图了,都能找到,附上自己写的源代码,有一个题有点问题,以后有空再看,今天太累了
HDU 2000
#include<iostream>
using namespace std;
int main(){
char a,b,c;
while(cin>>a>>b>>c){
if((int)a>(int)b) {
swap(a,b);
}
if((int)a>(int)c){
swap(a,c);
}
if((int)b>(int)c){
swap(b,c);
}
cout << a<<" "<<b<<" "<<c << endl;
}
return 0;
}
HDU2001
#include<iostream>
#include<cmath>
using namespace std;
int main(){
double x1,x2,y1,y2;
while(cin>>x1>>y1>>x2>>y2){
double dx=x1-x2;
double dy=y1-y2;
double d=sqrt(dx*dx+dy*dy);
printf("%.2lf\n",d);
}
return 0;
}
HDU2002
#include<iostream>
using namespace std;
const double PI=3.1415927;
int main(){
double r,s;
while(cin>>r){
s=(4/3.0)*PI*r*r*r;
printf("%.3lf\n",s);
}
return 0;
}
HDU 2003
#include<iostream>
#include<cmath>
using namespace std;
int main(){
double x;
while(cin>>x){
printf("%.2lf\n",abs(x));
}
return 0;
}
HDU 2004
#include<iostream>
using namespace std;
int main(){
double x;
while(cin>>x){
if(x<0||x>100) cout << "Score is error!" << endl;
else{
if(x<=59) cout << "E" << endl;
if(x>=60&&x<=69) cout << "D" << endl;
if(x>=70&&x<=79) cout << "C" << endl;
if(x>=80&&x<=89) cout << "B" << endl;
if(x>=90) cout << "A" << endl;
}
}
return 0;
}
HDU 2005
#include<iostream>
using namespace std;
int day[]={31,28,31,30,31,30,31,31,30,31,30,31};
//闰年的定义有点麻烦
int main(){
int a,b,c,days;
while(scanf("%d/%d/%d",&a,&b,&c)!=EOF){
days=0;
if(a%400==0||(a%4==0&&a%100!=0)){
day[1]=29;
}
else{
day[1]=28;
}
for(int i=0;i<b-1;i++){
days+=day[i];
}
days+=c;
cout << days << endl;
}
return 0;
}
HDU 2006
#include<iostream>
using namespace std;
int main(){
int n;
while(cin>>n){
int sum=1;
while(n--){
int x;
cin>>x;
if(x%2!=0) sum*=x;
}
cout << sum << endl;
}
return 0;
}
HDU 2007
#include<iostream>
using namespace std;
int main(){
int m,n;
while(cin>>m>>n){
int x,y;
x=0,y=0;
if(m>n) swap(m,n);
for(int i=m;i<=n;i++){
if(i%2==0) x+=i*i;
else y+=i*i*i;
}
cout << x <<" "<< y << endl;
}
return 0;
}
HDU 2008
#include<iostream>
using namespace std;
int main() {
int n;
int a;//负数
int b;//0
int c;//正数
while(cin>>n&&n!=0){
a=0,b=0,c=0;
while(n--){
double x;
cin>>x;
if(x==0.0) b++;
if(x>0.0) c++;
if(x<0.0) a++;
}
cout << a <<" "<<b<<" " <<" "<<c<< endl;
}
return 0;
}
HDU 2009
#include<iostream>
#include<cmath>
using namespace std;
int main() {
double m,n;
while(cin>>n>>m){
double sum=n;
for(int i=1;i<m;i++){
sum+=sqrt(n);
n=sqrt(n);
}
printf("%.2lf\n",sum);
}
return 0;
}
HDU 2010
#include<iostream>
using namespace std;
//水仙花数
int main() {
int m,n;
while(cin>>m>>n){
//标记位数
int a,b,c;
int count=0;
for(int i=m;i<=n;i++){
a=i/100;
b=(i/10)%10;
c=i%10;
int x=a*a*a+b*b*b+c*c*c;
if(a*a*a+b*b*b+c*c*c==i) {
count=1;
cout << x << " ";
}
}
if(count==0) cout << "no" << endl;
else cout<<endl;
}
return 0;
}