标题:新人求解答
只看楼主
xstawt
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-5-13
结帖率:0
已结贴  问题点数:20 回复次数:2 
新人求解答
现在一个5行5列的随机数组   找出每一行最大的一个数看这个数是不是这一列最大的  如果是就提出     求解
搜索更多相关主题的帖子: 最大的 
2015-05-13 23:16
海无边
Rank: 2
等 级:论坛游民
帖 子:15
专家分:72
注 册:2011-9-28
得分:10 
程序代码:
#include <stdio.h>

int main()
{
    int a[5][5], b[5]={0,0,0,0,0};  //a[5][5]值自己初始化
    int c=0;
    int i, j;
    for(i=0; i<5; i++)
    {
        for(j=0; j<5; j++)
        {
            if(a[i][j] >= b[c])
                {
                    b[c] = a[i][j];
                }
        }
        c++;
    }
}


贴的刚写的C语言代码,思路一样的。
2015-05-13 23:31
lianyicq
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:26
帖 子:735
专家分:3478
注 册:2013-1-26
得分:10 
回复 楼主 xstawt
程序代码:
Option Explicit
Dim a(4, 4) As Single
Private Sub Command1_Click()
Dim i As Integer, j As Integer
  Text1.Text = ""

 
  For i = 0 To 4
    For j = 0 To 4
      a(i, j) = Round(Rnd, 3)
      Text1.Text = Text1.Text & a(i, j) & " "
    Next
    Text1.Text = Text1.Text & vbCrLf
  Next
  Text1.Text = Text1.Text & vbCrLf
  judge
End Sub

Private Sub Form_Load()
Me.Show
End Sub

Sub judge()
  Dim i As Integer, j As Integer, k As Integer
  Dim rowmax As Single
  Dim rowmaxp
  Dim s As Boolean 'Is the maxmium number of a column ture:yes false:no
  
   
    For i = 0 To 4
      rowmax = 0
      For j = 0 To 4
        If a(i, j) > rowmax Then
          rowmax = a(i, j)
          rowmaxp = j
        End If
      Next
      s = True
      For k = 0 To 4
        If rowmax < a(k, rowmaxp) Then s = False: Exit For
      Next
        If s = True Then Text1.Text = Text1.Text & rowmax & " in the " & i & " Row" & " is the maxmium number of the " & rowmaxp & " column" & vbCrLf
    Next
End Sub

大开眼界
2015-05-14 09:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-445265-1-1.html




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

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