Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define N 5
- #define M 30
- int main(){
- int polje[N][M];
- int n, sum=0;
- /*printf("Unesi velicinu stupaca: \n"); ovo mi tu ne stima
- do{
- scanf("%d",n);
- }while(n<=19||n>30);
- */
- srand((unsigned)time(NULL)); //generator random broja
- //ispunjavanje polja random brojevima
- for(int i=0;i<N;i++){
- for(int j=0;j<M;j++){
- polje[i][j]= -14 + (double)rand() / RAND_MAX * 10;
- }
- }
- //printam cijelu listu, nije potrebno
- for(int i=0;i<N;i++){
- for(int j=0;j<M;j++){
- printf("%d",polje[i][j]);
- }
- }
- //suma redova
- for(int i=0;i<N;i++){
- for(int j=0;j<M;j++){
- sum=sum+polje[i][j];
- }
- printf("\n\nSuma %d. reda je %d\n", i, sum);
- }
- sum = 0; //vracam sumu na nulu
- //suma za stupce
- for(int j=0;j<M;j++){
- for(int i=0;i<N;i++){
- sum=sum+polje[i][j];
- }
- printf("\n\nSuma %d. stupca je %d\n", j, sum);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement