Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define N 200
- typedef struct {
- int first_match;
- int matches;
- char string[N];
- } Eita;
- int analyze(char *or, Eita *eita) {
- int i, j = 0;
- int flag = 0;
- int result = 0;
- eita[0].matches = eita[1].matches = 0;
- for (i = 0; i < strlen(or); i++) {
- if (eita[0].string[i] == or[i]) {
- eita[0].matches++;
- if (!flag) {
- if (eita[1].string[i] != or[i]) {
- result = 1;
- flag = 1;
- }
- }
- }
- if (eita[1].string[i] == or[i]) {
- eita[1].matches++;
- if (!flag) {
- if (eita[0].string[i] != or[i]) {
- result = 2;
- flag = 1;
- }
- }
- }
- }
- return result;
- }
- int main() {
- int i, n, temp;
- char original[N];
- Eita eita[2];
- scanf("%d", &n);
- for (i = 0; i < n; i++) {
- scanf(" %[^\n]", original);
- scanf(" %[^\n]", eita[0].string);
- scanf(" %[^\n]", eita[1].string);
- temp = analyze(original, eita);
- printf("Instancia %d\n", i + 1);
- if (eita[0].matches > eita[1].matches) {
- printf("time 1\n");
- } else if (eita[0].matches < eita[1].matches) {
- printf("time 2\n");
- } else if (!temp) {
- printf("empate\n");
- } else {
- printf("time %d\n", temp);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement