consolidate all repos to one for archive
This commit is contained in:
119
semester_1/programiranje_1/Vaje/Vaja_9/Police/main.cpp
Normal file
119
semester_1/programiranje_1/Vaje/Vaja_9/Police/main.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void print(int polica [3][4]){
|
||||
for(int i = 0; i<3; i++){
|
||||
for(int j = 0; j < 4; j++){
|
||||
cout << polica [i][j] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void copy(int array1[3][4], int array2[3][4]){
|
||||
for(int i = 0; i<3; i++){
|
||||
for(int j = 0; j < 4; j++){
|
||||
array2[i][j] = array1[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void konecdneva(int array[3][4]){
|
||||
//roglicki 0,3
|
||||
array [0][3] = 0;
|
||||
|
||||
//jabolka 1,2
|
||||
array [1][2] = 0;
|
||||
|
||||
//paradiznik 2,2
|
||||
array [2][2] = 0;
|
||||
|
||||
//pomarance 1,0
|
||||
array [1][0] /= 2;
|
||||
|
||||
//fige 1,3
|
||||
array [1][3] /= 4;
|
||||
}
|
||||
|
||||
void simetricna(int array[3][4]){
|
||||
int isto = 1;
|
||||
for(int i = 0; i<3; i++){
|
||||
for(int j = 0; j < 4; j++){
|
||||
if(array[i][j] != array[j][i]){
|
||||
isto = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isto == 1){
|
||||
cout << "Matrika je simetricna \n \n";
|
||||
}else{
|
||||
cout << "Matrika ni simetricna \n \n";
|
||||
}
|
||||
}
|
||||
|
||||
void skalar(int array [3][4]){
|
||||
for(int i = 0; i<3; i++){
|
||||
for(int j = 0; j < 4; j++){
|
||||
array[i][j] *= 365;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bublesort(int array [3][4]){
|
||||
for (int j = 0; j < 4; j++){
|
||||
for (int i = 0; i < 4-j-1; i++){
|
||||
if(array[i]<array[i+1]){
|
||||
int tem = array [0][i];
|
||||
array [0][i] = array [0][i+1];
|
||||
array [0][i+1] = tem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int diagonala(int array [3][4]){
|
||||
int j = 0;
|
||||
int skupaj = 0;
|
||||
for(int i = 0; i<3; i++){
|
||||
array[i][j] = pow(array[i][j],3);
|
||||
skupaj += array[i][j];
|
||||
j++;
|
||||
}
|
||||
int povprecje = skupaj / 3;
|
||||
return povprecje;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int police [3][4] = {{ 8, 6, 4, 3},
|
||||
{12, 4, 10, 12},
|
||||
{ 4, 3, 13, 8}};
|
||||
int konec [3][4];
|
||||
//kopiraj police v konec array
|
||||
copy(police, konec);
|
||||
|
||||
//izpisi zacetne police
|
||||
cout << "Zacetne police \n";
|
||||
print(police);
|
||||
|
||||
//konec dneva
|
||||
konecdneva(konec);
|
||||
cout << "Konec dneva police \n";
|
||||
print(konec);
|
||||
simetricna(konec);
|
||||
|
||||
//mnozenje s skalarjem
|
||||
cout << "Zacetne police zmnozene z skalarjem \n";
|
||||
skalar(police);
|
||||
bublesort(police);
|
||||
print(police);
|
||||
|
||||
cout << endl << "Po diagonali na kub \n";
|
||||
int x = 0;
|
||||
x = diagonala(konec);
|
||||
print(konec);
|
||||
cout << "Povprecje je " << x << endl;
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user