Guest User

Untitled

a guest
Dec 13th, 2016
122
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<ctime>
  3. using namespace std;
  4. void zad1(char* tab[]);
  5. void zad2(int rzad,int kolumna,int *tab[]);
  6. int main(int argc, char* argv[]) {
  7. //zad1(argv);
  8. cout << endl;
  9. int rzad_main = 3, kolumna_main = 3, wartosc = 0;
  10. int** tablica = new int*[rzad_main];
  11. for (int i = 0; i < rzad_main; i++) {
  12. for (int j = 0; j < kolumna_main; j++) {
  13. tablica[i][j] = 1;
  14. //wartosc++;
  15. }
  16. }
  17. zad2(rzad_main, kolumna_main, tablica);
  18. system("pause");
  19.  
  20. }
  21. void zad1(char* tab[]) {
  22. //argv[1]-rzedu
  23. //argv[2]-kolumny
  24. //argc[3]-zakres b
  25. srand(time(NULL));
  26. int **array = new int*[atoi(tab[1])];
  27. for (int i = 0; i < atoi(tab[1]); i++) {
  28. array[i] = new int[atoi(tab[2])];
  29. }
  30. for (int i = 0; i < atoi(tab[1]); i++) {
  31. for (int j = 0; j < atoi(tab[2]); j++) {
  32. array[i][j] = rand()%(atoi(tab[3])+1);
  33. }
  34. }
  35.  
  36. for (int i = 0; i < atoi(tab[1]); i++) {
  37. for (int j = 0; j < atoi(tab[2]); j++) {
  38. cout << "tab[" << i << "][" << j << "]= " << array[i][j]<<", ";
  39. }
  40. cout << endl;
  41. }
  42. }
  43. void zad2(int rzad, int kolumna, int *tablica[]) {
  44. int max = 0, max_i = 0, max_j = 0;
  45. for (int i = 0; i < rzad; i++) {
  46. for (int j = 0; j < kolumna; j++) {
  47. if (tablica[i][j] > max) {
  48. max = tablica[i][j];
  49. max_i = i;
  50. max_j = j;
  51. }
  52.  
  53. }
  54. }
  55. cout << "najwieksza wartosc = " << max << ", na indeksie = [" << max_i << "][" << max_j << "]";
  56. }
RAW Paste Data