您的位置:首页 > 其它

【练习01】 简单题(1)1003

2013-03-11 16:54 429 查看
#include<iostream>
#include<string>
#include <iomanip>
using namespace std;

int main(){
int n, m;
int temp;
char ch[101];
string s;
cin>>n;
double count_line;
double count_case;
for(int i = 0; i < n; i++){//处理每个case
count_case = 0;
cin>>m;
for(int j = 0; j < m; j++){//处理case中的每一行
count_line = 0;
cin>>s;
strcpy(ch, s.c_str());
for(int k = 0; ch[k] != '\0'; k++){//处理每一行中的每个字符
if(ch[k] == '-'){
continue;
}else{
if(ch[k+1] == '-' || ch[k+1] == '\0'){
temp = ch[k] - 48;
count_line += temp;
}else{
temp = (ch[k] - 48) * 10 + (ch[k + 1] - 48);
count_line += temp;
k++;
}
}
}
if(j == 0){
count_case = count_line;
}else{
count_case = (count_case * count_line) / (count_case + count_line);
}
}
cout.setf(ios::fixed,ios::floatfield);   // floatfield set to fixed
cout.precision(2);
cout<<count_case<<endl;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: