Skip to content

Commit

Permalink
Added 2015 codes
Browse files Browse the repository at this point in the history
  • Loading branch information
szymmirr authored Sep 26, 2020
1 parent dcf8f11 commit 4178886
Show file tree
Hide file tree
Showing 13 changed files with 469 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 2015/C++/fibonacci.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iostream>

using namespace std;

int main()
{
int n,a,b;
cin >> n;
a=0;
b=1;
for(int i=0; i<(n-1); i++)
{
b+=a;
a=b-a;
}
cout<<b;
return 0;
}
25 changes: 25 additions & 0 deletions 2015/C++/liczba-pierwsza.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>

using namespace std;

int main()
{
int n;
cin>>n;
for(int i=2;i<100;i++)
{
if (i>=n)
{
cout<<"tak";
break;
}
if (n % i==0)
{
cout<<"nie";
break;
}
}


return 0;
}
60 changes: 60 additions & 0 deletions 2015/C++/liczby-zaprzyjaznione.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream plik("dane.txt");
int x=0,y=0,sumax=0,sumay=0,sumaprzyjazni=0,dzielnyky=0,dzielnykymin=99999,xmin=0,ymin=0;
for (int j=0;j<500;j++)
{
sumax=0;
sumay=0;
dzielnyky=0;
plik>>x;
plik>>y;
for(int i=1;i<=x/2;i++)
{
if (x%i==0)
{
sumax+=i;
dzielnyky+=1;
}
}
for(int i=1;i<=y/2;i++)
{
if (y%i==0)
{
sumay+=i;
dzielnyky+=1;
}
}

if(sumax==y&&sumay==x)
{
sumaprzyjazni+=1;
if(dzielnyky<dzielnykymin)
{
dzielnykymin=dzielnyky;
xmin=x;
ymin=y;
}
}
}
cout<<sumaprzyjazni<<endl<<dzielnykymin<<endl;
for(int i=1;i<=xmin/2;i++)
{
if (xmin%i==0)
{
cout<<i<<" ";
}
}
cout<<endl;
for(int i=1;i<=ymin/2;i++)
{
if (ymin%i==0)
{
cout<<i<<" ";
}
}
return 0;
}
29 changes: 29 additions & 0 deletions 2015/C++/najwyzsza-suma.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
using namespace std;
int main()
{
int n,suma=0,makssuma=0;
cout<<"podaj dlugosc ciagu"<<endl;
cin>>n;
int tab[n];
cout<<"podaj ciag"<<endl;
for(int i=0;i<n;i++)
{
cin>>tab[i];
}

for(int i=0;i<n;i++)
{
suma=i;
for(int j=1;j<n;j++)
{
suma+=tab[j];
}
if(suma>makssuma)
{
makssuma=suma;
}
}
cout<<"najwyzsza suma wynosi: "<<makssuma;
return 0;
}
35 changes: 35 additions & 0 deletions 2015/C++/podciag-slowa.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>
using namespace std;
int main()
{
int pyknal,pyknelo=0;
string wyraz1,wyraz2;
cin>>wyraz1>>wyraz2;
for(int i=0;i<wyraz1.size();i++)
{
pyknal=0;
for(int j=0;j<wyraz2.size();j++)
{
if(wyraz1[i]!=wyraz2[j])
{
break;
}
if(wyraz1[i]==wyraz2[j])
{
pyknal+=1;
i+=1;
}

if(pyknal==wyraz2.size())
{
cout<<"tak"<<endl;
pyknelo=1;
}
}
}
if(pyknelo==0)
{
cout<<"nie"<<endl;
}
return 0;
}
17 changes: 17 additions & 0 deletions 2015/C++/python-has-power.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>

using namespace std;

int main()
{
int total = 2;
for (int x=5;x<15;x++)
{
if (x%2==0)
{
total+=x;
}
}

cout<<total;
}
17 changes: 17 additions & 0 deletions 2015/C++/suma-modulo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>

using namespace std;

int main()
{
int total = 2;
for (int x=5;x<15;x++)
{
if (x%2==0)
{
total+=x;
}
}

cout<<total;
}
29 changes: 29 additions & 0 deletions 2015/C++/szyfrowanie.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
using namespace std;
int main()
{
//banan
string slowo;
int klucz;
cout<<"podaj dlugosc klucza"<<endl;
cin>>klucz;
cout<<"podaj slowo do zaszyfrowania"<<endl;
cin>>slowo;
while(slowo.size()%klucz!=0)
{
slowo+='z';
}

for(int i=0;i<slowo.size();i+=klucz)
{
char tempek=slowo[i];
slowo[i]=slowo[i+klucz-1];
for(int j=i+klucz-1;j>i+klucz-3;j--)
{
slowo[j]=slowo[j-1];
}
slowo[i+1]=tempek;
}
cout<<slowo;
return 0;
}
23 changes: 23 additions & 0 deletions 2015/Java/CzerwoneTlo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package oboze;

import java.awt.Color;

import javax.swing.*;

public class heheklasa2 {

public static void main(String[] args)
{
JFrame f=new JFrame();
JPanel p=new JPanel();
JButton b=new JButton("OK");
JLabel l=new JLabel();
p.setBackground(Color.RED);
f.add(p);
p.add(b);
f.setSize(300, 300);
f.setVisible(true);

}

}
59 changes: 59 additions & 0 deletions 2015/Java/Eventy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package iwent;

import javax.swing.*;

import java.awt.Color;
import java.awt.event.*;
public class huehueivent implements ActionListener
{

JFrame f;
JPanel p;
JButton b1;
JButton b2;
JLabel l1;
JLabel l2;
JTextField t;
huehueivent()
{
f = new JFrame();
p = new JPanel();
b1 = new JButton("HUEHUE");
//b2 = new JButton("BEKA");
l1 = new JLabel("hue");
//l2 = new JLabel("smiesznie");
t= new JTextField(20);
f.add(p);
p.add(t);
//t.setPreferredSize(null);

p.add(b1);
//p.add(b2);
p.add(l1);
//p.add(l2);

b1.addActionListener(this);
//b2.addActionListener(this);
f.setSize(300, 300);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
b1.setBackground(Color.YELLOW);
b1.setText("OHHHHHHHHHHHHHHHHHHHHHH");
if(e.getSource()==b1)
{
l1.setText(t.getText());
}
if(e.getSource()==b2)
{
//l2.setText("kliknieto button2");
}
}
public static void main(String[] args) {

huehueivent okieneczko = new huehueivent();

}

}
Loading

0 comments on commit 4178886

Please sign in to comment.