Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define N 5
- int main(void){
- int matrix[N][N];
- int coeff = 1;
- for(int i = 0; i<N; i++){
- for(int j = 0; j<N; j++){
- matrix[i][j] = coeff;
- coeff++;
- }
- }
- puts("Stampa della matrice completa");
- for(int i = 0; i<N; i++){
- for( int j = 0; j<N; j++){
- printf("%d\t", matrix[i][j]);
- }
- puts("");
- }
- puts("\nStampo triangolo superiore");
- for(int i = 0; i<N; i++){
- for( int j = i+1; j<N; j++){
- printf("%d\t", matrix[i][j]);
- }
- puts("");
- }
- puts("\nAltro modo di esplorare un triangolo superiore");
- for(int h = 1; h<N; h++){
- for(int i = 0, j = h; i<N-h; i++, j++){
- printf("%d\n", matrix[i][j]);
- }
- puts("");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement