标题:不知道该怎么定义好类,弄得好累啊。。。。
取消只看楼主
黄辉
Rank: 4
等 级:业余侠客
帖 子:106
专家分:255
注 册:2013-4-28
结帖率:100%
已结贴  问题点数:18 回复次数:1 
不知道该怎么定义好类,弄得好累啊。。。。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Microsoft.VisualBasic;

namespace p110_6跳水
{
    public class getBestPosition
    {
        public int sum;
        public void BestPosition(int number, int sum, out int[] position)
        {
            int i;
            int flat;
            this.sum = sum;
            position = new int[number];

            for (i = 0; i < number; i++)
            {
                position[i] = 1;//该位置的跳水

            }

            for (i = 1; i < sum + 1; i++)
            {
                flat = 0;
                for (i = 0; i < number; i++)
                {
                    if (position[i] == 1)
                    {
                        flat++;
                        if (flat % 7 == 0)//满足条件的跳水
                        {
                            position[i] = 0;//将跳了水的置0;

                        }
                    }
                    
             if (flat == i)
             {
                 i = 1;
             }
                    
                }
            }
        }
        class Program
        {
            static void Main(string[] args)
            {
                int sum;
                int number;
                int i;
                getBestPosition p = new getBestPosition();
                Random rand = new Random();
                sum = rand.Next(50);
                number = sum;
                int[] position = new int[sum];

                p.sum = sum;
                p.BestPosition(number, sum, out position);

                Console.Write("跳水的顺序:");
                for (i = 0; i < number; i++)
                {
                    if (position[i] == 0)
                    {

                        Console.WriteLine(i + 1);
                    }
                }
                Console.Write("跳水的人的总数:");
                Console.WriteLine(sum);


            }
        }
    }
}

我想把跳水的一个个输出,我的类好像出了问题了,他只跳到第二遍就无法循环了,题目的要求是一堆人围成一圈,数到7的就跳水;求路过的朋友帮帮忙!
搜索更多相关主题的帖子: namespace void position public number 
2013-05-17 14:35
黄辉
Rank: 4
等 级:业余侠客
帖 子:106
专家分:255
注 册:2013-4-28
得分:0 
不行啊。。。

你不勇敢,谁替你坚强。。。
2013-05-18 19:47



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




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

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