日期:2014-05-17 浏览次数:20845 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ch5_6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class people
{
public void getjumpnum(int personnum, out int[] jumpnum)
{
jumpnum = new int[personnum+1];//定义personnum数组
int i,n=0, flag=0,k=1;
int[] j = new int[personnum + 1];//定义局部变量
for (i = 1; i <=personnum; i++)
{
j[i] = 1;//表示该位置上未跳水
}
for (i = 1; i <= personnum+1; i++)
{
if (i == personnum+1)//当i超过人数,给i初始化1
i = 1;
flag += j[i];
if (flag == 7)
{ n++; j[i] = 0; jumpnum[k++] = i; flag = 0; }// j[i] = 0表示该位置上跳水, jumpnum[k++] = i记录位置,flag初始化
if (n == personnum)//n来控制循环
&nb