2016/11/30

M90H023:三角形重心

//公式:(a1+a2+a3/3,b1+b2+b3/3)
#include <iostream>
using namespace std;
int main(){
	 double a1=0,a2=0,a3=0;
	 double b1=0,b2=0,b3=0;
	 double x=0,y=0;
	 cin>>a1;
	 cin>>b1;
	 cin>>a2;
	 cin>>b2;
	 cin>>a3;
	 cin>>b3;
	 x=(a1+a2+a3)/3;
	 y=(b1+b2+b3)/3;
	 cout <<"("<<x<<","<<y<<")";
}

M90H011:整數商餘

#include <iostream>
using namespace std;
int main(){
     int a=0,b=0,c=0,t=0;
	 cin>>a;
	 cin>>b;
	 c=a/b;
	 t=a%b;
	 cout << endl;
	 cout <<a<<" / "<<b<<"="<<c<<"\n";
	 cout <<a<<" mod "<<b<<"="<<t;
}

F020:計算BMI

#include <iostream>
using namespace std;
int main(){
        double w,h,bmi;
 cin>>h;
 cin>>w;
 bmi=w/(h*h);
 cout << bmi<<"\n";
 if(bmi<18.5)cout << "too thin";
 else if(bmi>=18.5&&bmi<24)cout << "standard";
 else cout <<"too fat";
 return 0;
}

M90H007:考試調分(低成60高100)

#include <iostream>
using namespace std;
int main(){
    int a,minScore=9999,maxScore=-9999;
    int scores[60];
    for(int i=0;i<60;i++){
     cin >>a;
     scores[i]=a;
     if(a>maxScore) maxScore=a;
     if(a<minScore) minScore=a;
    }
    for(int i=0;i<60;i++){
     int ans=(100-60)*(scores[i]-minScore)/(maxScore-minScore)+60;
     cout <<ans<<"\n";
    }
 return 0;
}