Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main ()
- {
- int i, j;
- FILE *mat;
- mat = fopen("matriz1.txt", "w");
- if (!mat)
- {
- printf("Erro ao abrir o arquivo!\n");
- exit(0);
- }
- else
- {
- for (i = 0; i < 6; ++i)
- {
- for (j = 0; j <6; ++j)
- {
- if ((i == 0 || i == 5) || (j == 0 || j == 5))
- {
- fprintf(mat, "1");
- if (j < 5) fprintf(mat, " ");
- }
- else if ((i == 1 || i == 4) || (j == 1 || j == 4))
- {
- fprintf(mat, "2 ");
- }
- else fprintf(mat, "3 ");
- }
- fprintf(mat, "\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement