-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhotel.c
56 lines (41 loc) · 740 Bytes
/
hotel.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"cs50.h"
#define MAXN 100
#define MAXM 200
int main (void)
{
int N, M;
string number = GetString();
strtok(number, " ");
string test = strtok(NULL, " ");
M = atoi(test);
N = atoi(number);
int matrix[MAXN][MAXM];
int i,j;
for (i = 0; i < N; i++)
{
string line = GetString();
for (j= 0; j< M; j++)
matrix[i][j] = (line[j] == '0'? 0: 1);
}
int S = GetInt();
int cpt = 0;
for (i = 0; i < N; i++)
{
for (j= 0; j< M; j++)
{
if (matrix[i][j] == 0)
cpt++;
else
cpt = 0;
if (cpt == S)
break;
}
if (cpt == S)
break;
}
printf("%d" , (cpt == S));
return 0;
}