找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 646|回复: 2

循環出錯了!!

[复制链接]
发表于 2009-10-3 09:39:37 | 显示全部楼层 |阅读模式 IP:江苏南通
急用。各位姐姐哥哥。帮忙。谢谢!!



下面的“總和”輸出錯了``
哥哥姐姐們幫我看看啊!!!謝謝了`!!!!
using System.Windows.Forms;

public class TestArray
{
static string output;
//求部门的和
static int sum(int[,] s, int k)
{
int total = 0;
for (int i = 0; i < s.GetLength(1); i++)
total += s[k, i];
return total;
}
//求季度的和
static int Sum(int[,] a, int l)
{
int Total = 0;
for (int i = 0; i < a.GetLength(1); i++)
Total += a[l, i];
return Total;
}
//控制输出方式
static void buildstring(int[,] sales)
{
output=" ";
for (int i = 0; i < sales.GetLength(1); i++)
output += " 季度" + i + " ";
output += "总和";
for (int i = 0; i < sales.GetLength(0); i++)
{
output += "\n部门" + i + " ";
output += "总和";
for (int j = 0; j < sales.GetLength(1); j++)
output += sales[i, j] + " ";
}
}
//主函数
static void Main()
{
int[,] sales ={ { 750, 660, 910, 800 }, { 800, 700, 950, 900 }, { 700, 600, 750, 600 }, { 850, 800, 1000, 950 }, { 900, 800, 960, 980 } };
output = "\t各季销售数字\n";
buildstring(sales);
for (int i= 0; i < sales.GetLength(1); i++)
output += sum(sales, i);
for (int i = 0; i < sales.GetLength(0); i++)
{
output += Sum(sales, i);
for (int j = 0; j < sales.GetLength(1); j++)
output += sales[i, j];
}
MessageBox.Show(output, "输出结果");
}
}


編寫一個程序,輸出5個部門每一季度的銷售數字!
輸出結果如下:
季度1 季度2 季度3 季度4 總和
部門1 750 660 910 800
部門2 800 700 950 900
部門3 700 600 750 600
部門4 850 800 1000 950
部門5 900 800 960 980
總和


應循環輸出,並計算出總和!!
发表于 2009-11-3 11:05:11 | 显示全部楼层 IP:韩国
好贴就是好贴。。。
回复

使用道具 举报

发表于 2010-3-9 07:05:05 | 显示全部楼层 IP:台湾
偶啥时才能熬出头啊.现在金钱好少,好少,慢慢做吧。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 11:25 , Processed in 0.250099 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表