现在的位置: 首页 > 综合 > 正文

POJ 1003 Hangover and 1004 Financial Management

2013年10月06日 ⁄ 综合 ⁄ 共 401字 ⁄ 字号 评论关闭

开始做水题了~~欧耶!

POJ 1003 Hangover

这道题so easy的说~~

#include<iostream>
using namespace std;
int main(){
float c;
int n; //the number of the cards
float len=0;
while(cin>>c&&c!=0){
int i=2;
while(len<c){
len+=1.0/i;
i++;
}
cout<<i-2<<" card(s)"<<endl;
len=0;
}
return 0;
}

poj 1004 Financial Management

就是求平均,读懂题就ok~~

#include <iostream>
using namespace std;
int main()
{
	float sum=0;
	float n;
	for(int i=0;i<12;i++){
		cin>>n;
		sum+=n;
	}
 	cout<<"$"<<sum/12<<endl;
	return 0;
}

抱歉!评论已关闭.