| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 891 人关注过本帖
标题:循環出錯了!!
只看楼主 加入收藏
y998601
Rank: 1
等 级:新手上路
威 望:1
帖 子:141
专家分:0
注 册:2006-10-21
收藏
得分:0 

在前面已经修改后的那个程序添加上using System;就可以了

[此贴子已经被作者于2006-10-25 16:46:40编辑过]


三个臭皮匠,顶一个诸葛亮~~~
2006-10-25 16:45
chzh
Rank: 1
等 级:新手上路
帖 子:127
专家分:0
注 册:2006-10-24
收藏
得分:0 

哦``3Q3Q```呵呵``!!


為了要遇見妳``我連呼吸都反複練習`
2006-10-25 17:04
lw817810
Rank: 1
等 级:新手上路
帖 子:79
专家分:7
注 册:2006-4-4
收藏
得分:0 


控制台下:

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
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[,] depart ={ { 750, 660, 910, 800 }, { 750, 660, 910, 800 }, { 750, 660, 910, 800 }, { 750, 660, 910, 800 }, { 750, 660, 910, 800 } };

Console.WriteLine("\t季度1\t季度2\t季度3\t季度4\t总和");
for (int i = 0; i < depart.GetLength(0); i++)
{
int sum = 0;
Console.Write("部门" + (i + 1) + "\t");
for (int j = 0; j < depart.GetLength(1); j++)
{
Console.Write(depart[i, j].ToString() + "\t");
sum += depart[i, j];

}
Console.Write(sum + "\n");
}
Console.Write("总和:\t");
for (int i = 0; i < depart.GetLength(1); i++)
{
int sum = 0;
for (int j = 0; j < depart.GetLength(0); j++)
{
sum += depart[j, i];
}
Console.Write(sum + "\t");
}
Console.WriteLine();
Console.Read();

}

}
}


2006-10-25 22:19
快速回复:循環出錯了!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021316 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved