C语言读取矩阵我有25个数以空格隔开 例如 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5.怎么读入 一个 a[5][5]的矩阵.或者有人能直接做出以下题目的.Problem 4Write a program zombie.c that prompts the user for a 5 \2 5 array

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/18 02:59:45
C语言读取矩阵我有25个数以空格隔开例如12345123451234512345.怎么读入一个a[5][5]的矩阵.或者有人能直接做出以下题目的.Problem4Writeaprogramzombie

C语言读取矩阵我有25个数以空格隔开 例如 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5.怎么读入 一个 a[5][5]的矩阵.或者有人能直接做出以下题目的.Problem 4Write a program zombie.c that prompts the user for a 5 \2 5 array
C语言读取矩阵
我有25个数以空格隔开 例如 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5.怎么读入 一个 a[5][5]的矩阵.
或者有人能直接做出以下题目的.
Problem 4
Write a program zombie.c that prompts the user for a 5 \2 5 array of zeros and ones (entered
consecutively row by row) and run the following game for three times:
\x0f Each element of the array is either a zombie (if it is 0) or a human (if it is 1).
\x0f The neighbors of each elements are those horizontally,vertically,or diagonally adjacent to
it,hence corner elements have three neighbors,elements on the side have \x0cve neighbors,and
elements in the middle have eight neighbors.
\x0f At each iteration of the game the following events occur:
{ Any human with less than two (namely 0 or 1) human neighbors is attacked by the
zombies and becomes a zombie.
{ Any zombie with more than two (namely 3 up to 8) human neighbors is cured by the
humans and becomes a human.
Denoting zombies by - and humans by \3,the program prints the initial state of the game (provided
by the user),and then runs the above iterations three times,printing the new state each time.

C语言读取矩阵我有25个数以空格隔开 例如 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5.怎么读入 一个 a[5][5]的矩阵.或者有人能直接做出以下题目的.Problem 4Write a program zombie.c that prompts the user for a 5 \2 5 array
int main()
{
int a[5][5];
int i,j;
for(i=0;i