Brojevi U Matrici Djeljivi S 3 I Veći Od 7!

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Brojevi u matrici djeljivi s 3 i vei od 7!

#include<stdio.h>
int a[8][8];
void _UPIS(int n, int m) { int i,j;
for(i=0;i<n;i++){
for(j=0;j<m;j++){
printf("Unesite a[%d][%d] element niza: ", i+1,j+1);
scanf("%d",&a[i][j]); } } }
void _ISPIS(int n, int m) {
int i,j;
for(i=0;i<n;i++){
for(j=0;j<m;j++){
printf("%d \t", a[i][j]);
}printf("\n"); } }
void main(){
int n,m,b=0,i,j; do{
printf("Unesite broj redaka matrice: ");
scanf("%d",&n); }while(n<2||n>6);
do { printf("Unesite broj stupaca matrice: ");
scanf("%d",&m); }while(m<2||m>6);
_UPIS(n,m); _ISPIS(n,m);
for(i=0;i<n;i++){
for(j=0;j<m;j++){
if(a[i][j]>7){
if(a[i][j]%3==0) b++; } } }
printf("U matrici ima %d brojeva koji su djeljivi sa 3 i vecih od 7\n", b); }

Koliko prostih brojeva ima u matrici!


int a[6][6];
void UPIS(int n, int m) { int i,j;
for(i=0;i<n;i++) {
for(j=0;j<m;j++) {
printf("Unesite a[%d][%d] element niza: ", i+1,j+1);
scanf("%d",&a[i][j]); } } }
void ISPIS(int n, int m) { int i,j;
for(i=0;i<n;i++) {
for(j=0;j<m;j++) {
printf("%d \t", a[i][j]); }
printf("\n"); } } int main() {
int n,m,s=0,i,j; do {
printf("Unesite broj redaka matrice: ");
scanf("%d",&n); }
while(n<2||n>6); do {
printf("Unesite broj stupaca matrice: ");
scanf("%d",&m); }
while(m<2||m>6);
UPIS(n,m); ISPIS(n,m);
for(i=0;i<n;i++) {
for(j=0;j<m;j++) {
if(a[i][j]%2==0) s++; } }
printf("U matrici ima %d prostih brojeva", s);
return 0; }
Produkt matrica!
#include <stdio.h>
main() {
int a[10][10], b[10][10], c[4][4], i, j, k, suma=0; //uzimam a[4][6] i b [7][4]
for(i=0; i<10; i++) {
for(j=0; j<10; j++) {
a[i][j]=0;
b[i][j]=0; } }
for(i=0; i<4; i++) {
for(j=0; j<6; j++) {
printf("Unesi u %d stupac i %d redak prve matrice: ", i, j);
scanf("%d", &a[i][j]); } }
for(i=0; i<7; i++) {
for(j=0; j<4; j++) {
printf("Unesi u %d stupac i %d redak druge matrice: ", i, j);
scanf("%d", &b[i][j]); } }
for(i=0; i<4; i++) {
for(j=0; j<4; j++) {
for(k=0; k<7; k++) {
suma = suma+a[i][k]*b[k][j]; }
c[i][j]=suma;
suma = 0; } }
printf("Produkt matrica je: \n");
for (i = 0 ;i < 4 ;i++) {
for (j= 0 ;j< 4 ; j++){
printf("%d\t", c[i][j]); }
printf("\n"); }
scanf("%d");
return 0; }

Potenciranje matrice!
#include <stdio.h>
#include <math.h>
main() {
int n, i, j, k, pot, p, suma=0;
do { printf("Unesi n matrice: ");
scanf("%d", &n);
} while(n<2 || n>=10);
int a[n][n], b[n][n];
do { printf("Unesi pot: ");
scanf("%d", &pot);
}while(n<2);
for(i=0; i<n; i++) {
for(j=0; j<n; j++) {
printf("Unesi u %d stupac i %d redak matrice: ", i, j);
scanf("%d", &a[i][j]); } }
for(p=0; p<pot; p++) {
for(i=0; i<n; i++) {
for(j=0; j<n; j++) {
for(k=0; k<n; k++) {
suma = suma+a[i][k]*a[k][j]; }
b[i][j]=suma;
suma = 0; } } }
printf("Potencirana matrica matrica je: \n");
for (i = 0 ;i < n;i++) {
for (j= 0 ;j< n; j++) {
printf("%d\t", b[i][j]); }
printf("\n"); }
scanf("%d");
return 0; }

Zbroj elemenata glavne dijagonale!


float a[8][8];
void UPIS (float n) { int i,j;
for(i=0;i<n;i++) {
for(j=0;j<n;j++) {
printf("Unesite a[%d][%d] element niza: ", i+1,j+1);
scanf("%f",&a[i][j]); } } }
void ISPIS (float n) { int i,j;
for(i=0;i<n;i++) {
for(j=0;j<n;j++) {
printf("%.2f \t", a[i][j]); }
printf("\n"); } }
int main() { int n,i,j;
float gl=0; do {
printf("Unesite broj elemenata matrice: ");
scanf("%d",&n); }
while(n<2||n>8);
UPIS(n);
ISPIS(n);
for(i=0; i<n; i++) {
for(j=0; j<n; j++) {
if (i==j)
gl+=a[i][j]; } }
printf("Zbroj elemenata glavne dijagonale je %.2f", gl); }

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy