还在做的作业

发布时间:2023-11-08 14:07:09
贴主:银河美术馆
热度:1

银河美术馆 2024-10-26

#include<iostream>

using namespace std;

int main() {

 int n;

 cout << "请输入有多少个学生:";

 cin >> n;

 bool* a = new bool[n]();

 int num = 0, time=0;

 bool* five = a;

 while (1)

 {

  for (int i = 0; i < n; i++) {

   if(a[i]==0)

   time++;

   if (time == 5) {

    num++;

    time = 0;

    *(five+i) = 1;

   }

   if (num == n - 1)

    break;

  }

  five = a;

  if (num == n - 1)

   break;

 }

 for (int i = 0; i < n; i++) {

  if (*(five+i) == 0) {

   cout << "结果为:第" << i + 1<<"个同学";

   break;

  }

 }

}

(0)

Copyright 2016 - 2024 XUJC ACM Team
闽ICP备2020022076号-1