Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cw01.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include "conio.h"
- #include "time.h"
- #include <iostream>
- int _tmain(int argc, _TCHAR* argv[])
- {
- srand(time(NULL));
- int t[5][5];
- int i,j;
- i=0;
- while(i<5){
- j=0;
- while(j<5){
- t[i][j]=rand()%10 -0;
- j++;
- }
- i++;
- }
- printf("Wszystkie elementy:\n");
- for(i=0;i<5;i++){
- for(j=0;j<5;j++){
- printf("%2d",t[i][j]);
- }
- printf("\n");
- }
- printf("\nElementy NA przekatnej:\n");
- for(i=0,j=0;i<5,j<5;i++,j++){
- if(i==j){
- printf("%2d",t[i][j]);
- }
- }
- printf("\n");
- printf("\nElementy NAD glowna przekatna:\n");
- for(i=0;i<4;i++){
- for(j=i+1;j<5;j++){
- printf("%2d",t[i][j]);
- }
- printf("\n");
- }
- printf("\nElementy POD glowna przekatna:\n");
- for(i=0;i<5;i++){
- for(j=0;j<5;j++){
- if(j<i){
- printf("%2d",t[i][j]);
- }
- }
- printf("\n");
- }
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement