consolidate all repos to one for archive

This commit is contained in:
2025-01-28 13:46:42 +01:00
commit a6610fbc7a
5350 changed files with 2705721 additions and 0 deletions

View File

@@ -0,0 +1,170 @@
#include <iostream>
using namespace std;
void izpis(const int array[], const int x){
for(int i = 0; i<x; i++){
cout << array[i] << " ";
}
cout << endl << endl;
}
void obrniNiz(const char string[], char invstring[], const int x){
for(int i = 0; i < x; i++){
invstring[i] = string[x-1-i];
}
}
void znaki(const char string[], const int x, int &samoglasniki, int &soglasniki){
samoglasniki = 0;
soglasniki = 0;
for(int i = 0; i < x; i++){
if (string[i] == 'a' || string[i] == 'e' || string[i] == 'i' || string[i] == 'o' || string[i] == 'u' || string[i] == 'A' || string[i] == 'E' || string[i] == 'I' || string[i] == 'O' || string[i] == 'U'){
samoglasniki++;
}else{
soglasniki++;
}
}
}
int primerjaj(const char string1[], const char string2[], const int x){
int enakost = 1;
for(int i = 0; i < x; i ++){
if(string1[i] != string2[i]){
enakost = 0;
}
}
return enakost;
}
void zdruzi(const char string1[], const char string2[], char string[], const int x){
for(int i = 0; i < x; i++){
string[i] = string1[i];
string[x+i] = string2[i];
}
}
void tolowercase(char string1[], int x){
for(int i = 0; i < x; i++){
if(string1[i] >= 65 && string1[i] <= 92){
string1[i] = string1[i] + 32;
}
}
}
void charvint(const char string[], int array[], const int x){
for(int i = 0; i < x; i++){
array[i] = int(string[i]);
}
}
void intvcahr(const int array[], char string[], const int x){
for(int i = 0; i < x; i++){
string[i] = char(array[i]);
}
}
void piramida(const char string[], const int x){
int rec = x;
for(int i = 0; i < x; i++){
for(int k=0;k<rec-1;k++)cout<<" ";
rec--;
if(i == 0){
cout << string[i] << endl;
}else{
cout << string[i];
for(int j = 0; j < i*2; j++){
cout << " ";
}
cout << string[i] << endl;
}
}
cout << string << string << endl;
}
int main()
{
char string1[200];
char string2[200];
char string3[200];
char string4[200];
int array[200];
int x, y, z;
cout << "Vpisi dolzino besede: ";
cin >> x;
cout << "Vpisi niz: ";
cin >> string1;
cout << "Vpisi drugi niz: ";
cin >> string2;
cout << endl;
//obrne string
obrniNiz(string1,string3,x);
cout << "Obrnjen niz: " << string3 << endl << endl;
//presteje samoglasnike in soglasnike
znaki(string1, x, y, z);
cout << "Stevilo samoglasnikov: " << y << endl << endl;
cout << "Stevilo soglasnikov: " << z << endl << endl;
//primerjaj string1 in string2(inv string1) da ugotovis ali je ponidrom
y = primerjaj(string1, string3, x);
if(y == 1){
cout << "Beseda je polindrom" << endl << endl;
}else {
cout << "Beseda ni polindrom" << endl << endl;
}
//primerjaj dva stringa
y = primerjaj(string1, string2, x);
if(y == 1){
cout << "Besedi sta enaki" << endl << endl;
}else {
cout << "Besedi nista enaki" << endl << endl;
}
//doda prvemu nizu znakov doda drugi niz znakov
zdruzi(string1, string2, string4, x);
cout << "Zdruzen niz: " << string4 << endl << endl;
//spremeni velike crke v male
tolowercase(string1,x);
cout << "Vse v malih crkah: " << string1 << endl << endl;
//spremeni char polje v int polje
charvint(string1, array, x);
cout << "Iz char v int: ";
izpis(array, x);
//spremeni int polje v char polje
intvcahr(array, string3, x);
cout << "Iz int v char: " << string3 << endl << endl;
//encript polje z 1 in 7 funkcijo in jo pomnozi z klucem
obrniNiz(string1, string3, x);
charvint(string3, array, x);
cout << "Vpisi kljuc: ";
cin >> y;
cout << endl;
for(int i = 0; i < x; i++){
array[i] *= y;
}
cout << "Inkriptiran text: ";
izpis(array, x);
//decript array
for(int i = 0; i < x; i++){
array[i] /= y;
}
intvcahr(array, string3, x);
obrniNiz(string3, string2, x);
cout << "Dekriptiran text: " << string2 << endl << endl;
// piramida
piramida(string1, x);
return 0;
}