将下列代码转换成c语言代码:#include <iostream> #include <algorithm> #include <cstdio> #include <cmath> #include <vector> #include <map> #include <string> #include <cstring> #define fast ios::sync_with_stdio(false),cin.tie(0) using namespace std; typedef pair<int, int> PII; typedef long long LL; const int N = 1010; int T; int f1, s1, f2, s2; vector<PII> v; string x[8] = {"11111111", "10000001", "10111101", "10111101", "10111101", "10111101", "10000001", "11111111"}; int main() { int n, m; scanf("%d %d", &n, &m); string s[N]; for(int i = 0; i < n; i ++ ) { cin >> s[i]; } for(int i = 0; i <= n - 8; i ++ ) { for(int j = 0; j <= m - 8; j ++ ) { int k, cnt = 0; for(k = 0; k < 8; k ++ ) { //cout << k << " " << x[k] << " " << s[i+k].substr(j, 8) << endl; if( x[k] == s[i+k].substr(j, 8) ) cnt ++; } if(cnt == 8) v.push_back({i, j}); } } sort(v.begin(), v.end()); for(int i = 0; i < 3; i ++ ) printf("%d %d\n", v[i].first, v[i].second); return 0; }
时间: 2024-03-23 22:41:28 浏览: 144
以下是将代码转换成 C 语言代码后的结果:
```c
#include <stdio.h>
#include <string.h>
#define fast {ios::sync_with_stdio(false); cin.tie(0);}
typedef struct PII {
int first, second;
} PII;
const int N = 1010;
int T, f1, s1, f2, s2;
PII v[N];
char x[8][9] = {"11111111", "10000001", "10111101", "10111101", "10111101", "10111101", "10000001", "11111111"};
int main() {
int n, m, i, j, k, cnt;
scanf("%d %d", &n, &m);
char s[N][N];
for(i = 0; i < n; i ++ ) {
scanf("%s", s[i]);
}
for(i = 0; i <= n - 8; i ++ ) {
for(j = 0; j <= m - 8; j ++ ) {
cnt = 0;
for(k = 0; k < 8; k ++ ) {
if( strcmp(x[k], s[i+k]+j) == 0 ) cnt ++;
}
if(cnt == 8) {
v[T].first = i;
v[T].second = j;
T ++;
}
}
}
for(i = 0; i < T; i ++ ) {
printf("%d %d\n", v[i].first, v[i].second);
}
return 0;
}
```
阅读全文