AC代码:

#include <iostream>
#include <iomanip>
using namespace std;
//计算数学期望值,可以自己直接通过数组的方式来实现
double haha[105][105];

int main()
{
//memset(haha,0,sizeof(haha));
int a,b;
while(cin>>a>>b&&(a||b))
{
for(int i = 0; i < a; i++){
for(int j = 0; j < b; j++){
cin>>haha[i][j];

}
}
//我现在的思路是将小的和小的相乘,所以最基本的要求就是排序,但是最后可以发现,排序失败了
for(int t = 0;t < b;t++){
for(int r = 1;r < a; r++)
for(int e = r;e > 0 ; e--)
if(haha[e][t] > haha[e-1][t]){
double temp = haha[e-1][t];
haha[e-1][t] = haha[e][t];

haha[e][t] = temp;
}
}
//将结果打印吧
/* for(int d =0;d<a;d++)
{for(int s = 0;s <b;s++)
cout<<haha[d][s]<<" ";cout<<endl;}*/
//排好顺序后就将结果全部保存到第一个中间
for(int w = 0; w <a;w++){
for(int y = 1; y <b;y++){

haha[w][0] *=haha[w][y];

}}
double zhangjie = 0;
for(int v = 0;v < a;v++)zhangjie+=haha[v][0];
cout<<fixed<<setprecision(4)<<zhangjie<<endl;
}
return 0;
}

本来这道题想法都很清楚了,在写的过程中发现保存变量的类型出了问题,结果就是改来改去还是没有全部改正过来,只好一步步的调试,走到最后AC。想说的就是使用二维数组的时候行与列之间的顺序到后来已经非常的混乱了,这个东西在以往也遇见过许多次,所以以后还是得好好练练这方面的东西了

csuoj1009的更多相关文章

随机推荐

  1. Js的两种post方式

    第一种提交post的方式是传统方式,判断浏览器进行post请求. var xmlobj; //定义XMLHttpRequest对象 function CreateXMLHttpRequest() { ...

  2. $.ajax({})方法success,error,complete,beforeSend使用例子及解释

    在与后台交互的时候,经常使用到jquery的$.ajax()方法来请求数据: 回调函数用的比较多的是success,但是complete.beforeSend.error函数也是很有用的: 下面是使用 ...

  3. 大数据时代之hadoop(一):hadoop安装

    1.hadoop版本介绍 0.20.2版本以前(不含该版本)的配置文件都在default.xml中. 0.20.x以后的版本不含有eclipse插件的jar包,由于eclipse的版本不一,所以就需要 ...

  4. ASP.NET Page执行顺序

    using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...

  5. POJ 3537 Crosses and Crosses(SG/还未想完全通的一道SG)

    题目链接 #include<iostream> #include<cstdio> #include<cstring> using namespace std; ]; ...

  6. 简单的Socket通信

    Socket简介 Socket又称"套接字",应用程序通常通过"套接字"向网络发出请求或者应答网络请求. 服务端步骤: • socket:创建服务器socket ...

  7. 正方形网格 TRIANGLE_STRIP连接

    unsigned int vIdx = 0, iIdx = 0; for (unsigned int stripRow = 0; stripRow < stripRows; stripRow++ ...

  8. LeetCode OJ 75. Sort Colors

    Given an array with n objects colored red, white or blue, sort them so that objects of the same colo ...

  9. SQL 列提取组成字符串

    SELECT BussinessNo = STUFF(REPLACE(REPLACE((SELECT N.business_no FROM T_delegate_list N WHERE N.g_mo ...

  10. K - Balance(动态规划专项)

    K - Balance Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit  ...