Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int MatrizIdentidade(int nxn)
- {
- if(nxn <= 0)
- return printf("Número de linhas (colunas) inválido.");
- for(int i = 1; i <= nxn; ++i)
- for(int j = 1; j <= nxn; ++j)
- printf("%d%s", i == j, j == nxn ? ("\n") : (""));
- return 1;
- }
- main()
- {
- MatrizIdentidade(3);
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment