sikham Posted January 6, 2005 Share Posted January 6, 2005 czy znajdzie sie ktoś kto powie mi jak napisać program tworzący 2 macierze 5x5 wypełnione losowymi liczbami z zakresu i z tych macierzy zrobić macierz gdzie elementy nad główną przekątną to suma pod przekątną to różnica aprzekątna to iloraz odpowiednich elementów macierzy wejściowych Link to comment Share on other sites More sharing options...
sikham Posted January 6, 2005 Author Share Posted January 6, 2005 ps. mam czas do 9.45 PROSZE O POMOC :) Link to comment Share on other sites More sharing options...
Luke3D Posted January 6, 2005 Share Posted January 6, 2005 ja troche znam c++ to może ci pomoge, ale.... co to są macierze? Link to comment Share on other sites More sharing options...
sikham Posted January 6, 2005 Author Share Posted January 6, 2005 tabela 2 wymiarowa o rozmiarach 5x5 może to cie naprowadzi interesuje mnie sama pętla for itd mam tyle i niewiem co jest źle bo niedziała tak jak powinno :((((((((((((( #include #include #include main() { int i,j,tabA[5][5],tabB[5][5],tabC[5][5]; randomize(); cout for(i = 0; i { for(j = 0; j { tabA[j]=random(101); cout } } cout for(i = 0; i { for(j = 0; j { tabB[j]=random(101); cout } } cout for(i = 0; i { for(j = 0; j { tabC[j] = tabA[j] + tabB[j]; cout } for(j = 0; j { tabC[j] = tabA[j] - tabB[j]; cout } for (j = 0; i=j; j++) { tabA[j] = tabA[j] * tabB[j]; cout } } getch(); return 0; } Link to comment Share on other sites More sharing options...
sanki Posted January 6, 2005 Share Posted January 6, 2005 co to za funkcja randomize ?? kompiluje ci sie toto wogole ?? Link to comment Share on other sites More sharing options...
sikham Posted January 6, 2005 Author Share Posted January 6, 2005 wszystko diała tylko niepotrafie wpisać w przekątną Link to comment Share on other sites More sharing options...
sanki Posted January 6, 2005 Share Posted January 6, 2005 w ostatnim forze zrob zamiast i=j i==j :-) czesty blad, a jezeli bedzie wyswietlac w zlej kolejnosci, to zamien petle iterowane przez i na j i vice versa Link to comment Share on other sites More sharing options...
sikham Posted January 6, 2005 Author Share Posted January 6, 2005 dalej niemnoży tylko dodaje tą jeb@#$% przekątną Link to comment Share on other sites More sharing options...
sanki Posted January 6, 2005 Share Posted January 6, 2005 to pojedz to ifami for(i = 0; i {for(j = 0; j {if(j {tabC[j] = tabA[j] + tabB[j]; cout } else if(j > i) {tabC[j] = tabA[j] - tabB[j]; cout } else if (i==j) {tabA[j] = tabA[j] * tabB[j]; cout } } } Link to comment Share on other sites More sharing options...
sikham Posted January 6, 2005 Author Share Posted January 6, 2005 jesteś moim zbawicielem :D:D:D ostatną liczbe w przekątnej zawsze wychodzi 0 ;///////// czemu ? Link to comment Share on other sites More sharing options...
sanki Posted January 6, 2005 Share Posted January 6, 2005 kurcze u mnie jest ok, ale ja uzylem do generowania liczb losowy rand() z stdlib.h to randomize i random nie chcialo mi dzialac #include #include #include #include #include using namespace std; main() { int i,j,tabA[5][5],tabB[5][5],tabC[5][5]; coutsrand(time(NULL)); for(i = 0; i {for(j = 0; j { tabA[i][j]=(rand()%100)+1; cout } } coutfor(i = 0; i {for(j = 0; j { tabB[i][j]=(rand()%100)+1; cout } } coutfor(i = 0; i {for(j = 0; j {if(j>i) {tabC[i][j] = tabA[i][j] + tabB[i][j]; cout} else if(j {tabC[i][j] = tabA[i][j] - tabB[i][j]; cout} else if (i==j) {tabA[i][j] = tabA[i][j] * tabB[i][j]; cout} } } getch(); return 0; } Link to comment Share on other sites More sharing options...
sikham Posted January 6, 2005 Author Share Posted January 6, 2005 dalej 0 :| Link to comment Share on other sites More sharing options...
sanki Posted January 6, 2005 Share Posted January 6, 2005 no to widocznie to juz jest kwestia komputera i generatora licz, nie nalezy sie tym przejmowac ;p Link to comment Share on other sites More sharing options...
sikham Posted January 6, 2005 Author Share Posted January 6, 2005 Sanki wielkie dzieki zaliczyłem to "cuś" bez ciebie by było cieżko ;) Link to comment Share on other sites More sharing options...
sanki Posted January 6, 2005 Share Posted January 6, 2005 a ze tak spytam, co i gdzie studiujesz ?? Link to comment Share on other sites More sharing options...
sikham Posted January 6, 2005 Author Share Posted January 6, 2005 elektronike i telekomunikacje na politechnice koszalińskiej Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now