TOPIC

Presentation error!

Joao Gabriel Gavron asked 2 years ago

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int h = 1;

    int tmpA = 0;
    char a[8] = {0};
    int sizeA = 0;

    char *e = malloc(300001);

    int i = 0;

    do
    {
        scanf("%d", &tmpA);

        if (tmpA)
        {
            sprintf (a, "%d", tmpA);
            sizeA = strlen (a);

            scanf("%s", e);

            for (i = 0; e[i]; i++)
                if (e[i] == a[0])
                    if (!strncmp (&e[i], a, sizeA))
                        break;

            printf("Instancia %d\n", h++);

            if (e[i])
                printf("verdadeira\n\n");
            else
                printf("falsa\n\n");
        }
    }while (tmpA);

    free (e);

    return (0);
}

Remember not post solutions. Your post may be reviewed by our moderators.

  • Yogesh Chhetri replied 2 years ago

    Just Add line 32: if(h>1) printf("\n"); line 36: printf("verdadeira\n"); line 38: printf("falsa\n"); All the best for your Submission !