标签:输入格式 假设 iostream cout include 表示 整数 == col
问题描述
1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int n, a[101],p[20][5]; 6 cin >> n; 7 for (int i = 0; i < n; i++)cin >> a[i]; 8 for (int i = 0; i < 20; i++)for (int j = 0; j < 5; j++)p[i][j] = 5 * i + j + 1; 9 int k = 0; 10 int i = 0; 11 while (k < n) { 12 int j = 0; 13 while (j < 5 && p[i][j] == 0)j++; 14 if (i >= 20&&k<n){ //没有连坐了 15 for (int x = 0; x < a[k]; x++) 16 for (int i = 0; i < 20; i++) 17 for (int j = 0; j < 5; j++) { 18 if (p[i][j] != 0) { 19 cout << p[i][j] << " "; 20 p[i][j] = 0; 21 } 22 } 23 k++; 24 } 25 if ((a[k] + j) <= 5) { 26 int c = a[k] + j; 27 for (; j < c; j++) { 28 cout << p[i][j] << " "; 29 p[i][j] = 0; 30 } 31 cout << endl; 32 k++; 33 i = 0; 34 } 35 else i++; 36 37 } 38 return 0; 39 }
标签:输入格式 假设 iostream cout include 表示 整数 == col
原文地址:https://www.cnblogs.com/cqy1245053939/p/10137052.html