Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Data: 18/08/2022
- Programma:
- Scrivi un programma che riempe una matrice con la tavola pitagorica dei
- primi 10 numeri e la visualizza sullo schermo.
- */
- #include <stdio.h>
- #define LEN 10
- void loadMatrix(int matrix[][LEN]) {
- for (size_t i = 0; i < LEN; i++) {
- for (size_t j = 0; j < LEN; j++) {
- matrix[i][j] = (i + 1) * (j + 1);
- }
- }
- }
- void printMatrix(int matrix[][LEN]) {
- for (size_t i = 0; i < LEN; i++) {
- for (size_t j = 0; j < LEN; j++) {
- // Lascia 3 spazi per motivi di formattazione dell'output
- printf("%3.d ", matrix[i][j]);
- }
- printf("\n");
- }
- }
- int main() {
- int M[LEN][LEN];
- loadMatrix(M);
- printMatrix(M);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement