Advertisement
Cieslin

PPTabliceDynamiczneDwuwymiarowe

Dec 4th, 2017
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. // ConsoleApplication10.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <stdlib.h>
  6. #include <malloc.h>
  7. #include <Windows.h>
  8. int main()
  9. {
  10.     float **tab;
  11.     int wiersz, kolumny;
  12.     do
  13.     {
  14.         printf("Podaj liczbe wierszy: ");
  15.         scanf_s("%d", &wiersz);
  16.         printf("Podaj liczbe kolumn: ");
  17.         scanf_s("%d", &kolumny);
  18.     } while (wiersz < 0 || kolumny < 0);
  19.     tab = (float**)malloc(wiersz * sizeof(float*));
  20.     for (int i = 0; i<wiersz; i++)
  21.     {
  22.         tab[i] = (float*)malloc(kolumny * sizeof(float));
  23.     }
  24.     for (int i = 0; i < wiersz; i++)
  25.         for (int j = 0; j < kolumny; j++)
  26.         {
  27.             printf("T[%d][%d] = ", i + 1, j + 1);
  28.             scanf_s("%f", &tab[i][j]);
  29.         }
  30.  
  31.     for (int i = 0; i < wiersz; i++)
  32.     {
  33.         for (int j = 0; j < kolumny; j++)
  34.             printf("%.0f", tab[i][j]);
  35.         printf("\n");
  36.        
  37.     }
  38.  
  39.    
  40.     system("PAUSE");
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement