Τετάρτη 14 Νοεμβρίου 2012

KENO


#include <cstdlib>
#include <ctime>
#include <iostream>
#include <vector>

using namespace std;

class keno
{
    private:
        double balance;

    public:
        keno(){balance = 0;}

        void putDeposit(double amount)
        {balance += amount;}

        void lostBet(double dollar)
        {balance -= dollar;}

        void won1SpotGame(double dollar)
         {balance += (dollar * 3);}

         void won5SpotGame(double dollar, int m)
         {if (m == 3)
         balance += dollar;
         else if (m == 4)
         balance += (dollar * 10);
         else if (m == 5)
         balance += (dollar * 800);}

         void won12SpotGame(double dollar, int hit)
         {if (hit == 6)
         balance += (dollar * 5);
         else if (hit == 7)
         balance += (dollar * 32);
         else if (hit == 8)
         balance += (dollar * 200);
         else if (hit == 9)
         balance += (dollar * 1000);
         else if (hit == 10)
         balance += (dollar * 5000);
         else if (hit == 11)
         balance += (dollar * 25000);
         else if (hit == 12)
         balance += (dollar * 100000);}

         double getBalance () const
        {return balance;}
};

void showMenu();

int main()
    {
char* lost = "Sorry, you didn't win.";
int choice, deposit;
int num1, num5[5], num12[12];
cout<<"Enter your deposit amount: ";
cin>>deposit;
if(!cin.eof() && cin.good())
{
if(deposit > 0)
{
keno A;
A.putDeposit(deposit);
do{
showMenu();
cin>>choice;
switch(choice)
{
case 1: // 1 spot game
{
        int match1 = 0;
        int bet;
        cout<<"How much do you want to bet? ";
        cin>>bet;
        cout<<"Enter 1 number: ";
        cin>>num1;
        cout<<endl;
        srand(time(NULL));
        vector<bool> Randoms(61,false);
        for(int i=1;i<21; i++) {
        int j = rand() % (80 - 1) + 1 + 1;
        if(Randoms[j]) {
                --i;
        } else {
            Randoms[j]=true;
            cout<<j<<" ";

            }

        if(j == num1)
        match1++;

        if(i % 5 == 0)
         cout<<endl;
        }
        cout<<endl;
        if(match1 == 0)
        {
        cout<<lost <<endl;
        A.lostBet(bet);
        cout<<"Current balance is $" <<A.getBalance() <<endl <<endl;
        }
        else
        {
        cout<<"You got 1 match\n";
        A.won1SpotGame(bet);
        cout<<"Current balance is $" <<A.getBalance() <<endl <<endl;
        }
        break;
}

case 2: // 5 spot game
        {
        int bet5;
        int match5 = 0;
        cout<<"How much do you want to bet? ";
        cin>>bet5;
        cout<<"Enter 5 numbers: ";
        for(int x=0; x<5; x++)
        cin>>num5[x];
        cout<<endl;
        srand(time(NULL));
        vector<bool> Randoms(61,false);
        for(int i=1; i<21; i++) {
        int r = rand() % (80 - 1) + 1 + 1;
        if(Randoms[r]) {
                --i;
        } else {
            Randoms[r]=true;
            cout<<r<<" ";
        }
        for(int c=0; c<5; c++)

        if(r == num5[c])
        match5++;

        if(i % 5 == 0)
         cout<<endl;
        }
        cout<<endl;
        if(match5 == 0 || match5 == 1 || match5 == 2)
        {
        cout<<lost <<endl;
        A.lostBet(bet5);
        cout<<"Current balance is $" <<A.getBalance() <<endl <<endl;
        }
        else
        {
        cout<<"You got " <<match5  <<" matches\n" <<endl;
        A.won5SpotGame(bet5, match5);
        cout<<"Current balance is $" <<A.getBalance() <<endl <<endl;
        }
        break;
        }

case 3: // 12 spot game
 {
        int bet12;
        int match12 = 0;
        cout<<"How much do you want to bet? ";
        cin>>bet12;
        cout<<"Enter 12 numbers: ";
        for(int x=0; x<12; x++)
        cin>>num12[x];
        cout<<endl;
        srand(time(NULL));
        vector<bool> Randoms(61,false);
        for(int i=1;i<21; i++) {
        int t = rand() % (80 - 1) + 1 + 1;
        if(Randoms[t]) {
                --i;
        } else {
            Randoms[t]=true;
            cout<<t<<" ";
        }
         for(int c=0; c<12; c++)

        if(t == num12[c])
        match12++;

        if(i % 5 == 0)
         cout<<endl;
        }
        cout<<endl;
        if(match12 == 0 || match12 == 1 || match12 == 2 ||
        match12 == 3 || match12 == 4 || match12 == 5)
        {
        cout<<lost <<endl;
        A.lostBet(bet12);
        cout<<"Current balance is $" <<A.getBalance() <<endl <<endl;
        }
        else
        {
        cout<<"You got " <<match12  <<" matches\n";
        A.won5SpotGame(bet12, match12);
        cout<<"Current balance is $" <<A.getBalance() <<endl <<endl;
        }
        break;
        }

case 4:  cout<<"Final balance is $" <<A.getBalance() <<endl;
         if(A.getBalance() < 0)
         cout<<"Better luck next time.\n";
         break;

default: cout<<"Invalid selection. Please choose an option 1-4.\n\n";
}
}while(choice != 4);
}
else
cout<<"Your deposit cannot be negative\n";
}
else
cout<<"Invalid input\n";

return 0;
}

void showMenu()
{
    cout<<"------KENO------\n";
    cout<<"1. 1 Spot Game\n";
    cout<<"2. 5 Spot Game\n";
    cout<<"3. 12 Spot Game\n";
    cout<<"4. Quit & Cash Out\n";
    cout<<"-----------------\n";
    cout<<"Enter your choice: ";
}

Παρασκευή 4 Μαΐου 2012

THE MATRIX


/*
***THE MATRIX
*/

#include <windows.h> 
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>


using namespace std;

int main(int argc, char *argv[])
{
    int a;
    string array [42] = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9", " ", " ","?","!","#","*"};
    system("TITLE The Matrix");
    system("color 0A");
    while(1)
    {
   Sleep(45);  
    for(int i=0; i<27; i++)
             {
             a = rand()%42;
             cout << " " << array[a];
             cout << " ";
             }
             cout << endl;
    }
    getch();
    return 0;
}


Σάββατο 28 Απριλίου 2012

Ηρθε η νέα έκδοση Ubuntu 12.04

Διαθεσιμη η νεα εκδοση του Ubuntu Precise Pangolin 12.04 LTS


Η εκδοση 12.04 LTS θα εχει υποστηριξη 5 ετων, μεχρι και τον Απριλιο του 2017
Περισσοτερα μπορειτε να διαβασετε εδω http://www.ubuntu.com/desktop/features
Το .iso μπορειτε να το κατεβασε απο εδω για:
Ubuntu Desktop http://www.ubuntu.com/desktop/get-ubuntu/download
Ubuntu Server http://www.ubuntu.com/server/get-ubuntu/download
Kubuntu http://www.kubuntu.org/getkubuntu/download
Xubuntu http://xubuntu.org/getxubuntu/
Lubuntu http://lubuntu.net/blog/lubuntu-1204-now-available
Ubuntu Studio http://ubuntustudio.org/
Mythbuntu http://www.mythbuntu.org/downloads
Edubuntu http://edubuntu.org/download

Για τον σωστο τροπο εγγραφης του .iso δειτε εδω https://help.ubuntu.com/community/el/BurningIsoHowto

Για οποιον θελει, μπορει να δοκιμασει τη νεα εκδοση,
μεσα απο τον περιηγητη του http://ubuntu-gr.org/ubuntu/take-the-tour/12.04/el/

Σάββατο 21 Απριλίου 2012

Sound Virus

ΔΥΣΤΗΧΩΣ ΔΕΝ ΈΧΩ ΤΟΝ ΚΩΔΙΚΑ ,ΕΧΩ ΜΟΝΟ ΤΟ .exe file




downloal the above program


----------http://www.2shared.com/file/NYjBVwRR/Sound_Virus.html-----------


rar password: kalpos1993

"Beers = Java"

................................Ονομάζουμε την κλάση Gui.java..............................



import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class Gui extends JFrame
{
private JList leftlist;
private JList rightlist;
private JButton movebutton;
private static String[] beers = {"black","red","pilsner","blonde"};

public Gui()
{
super("Java=Beer");
setLayout(new FlowLayout());

leftlist = new JList (beers);
leftlist.setVisibleRowCount(3);
leftlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
add(new JScrollPane(leftlist));

movebutton = new JButton("Move -->");
movebutton.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
rightlist.setListData(leftlist.getSelectedValues());

}
}
);
add(movebutton);

rightlist = new JList();
rightlist.setVisibleRowCount(3);
rightlist.setFixedCellWidth(100);
rightlist.setFixedCellHeight(15);
rightlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
add(new JScrollPane(rightlist));
}
}



..........................Ονομάζουμε μια νέα κλάση Mpira.java............................ 



import javax.swing.JFrame;

class Mpira
{
public static void main(String[] args)
{

Gui go = new Gui();
go.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
go.setSize(300,200);
go.setVisible(true);


}
}

Colors' Panel



...........................Ονομάζουμε την κλάση Gui.java..........................


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class Gui extends JFrame
{
private JList list;
private static String[] colornames = {"black", "blue", "red","white","cyan","magenta"};
private static Color[] colors = {Color.BLACK, Color.BLUE, Color.RED, Color.WHITE,Color.CYAN,Color.MAGENTA};

public Gui()
{
super("title");
setLayout(new FlowLayout());

list = new JList(colornames);
list.setVisibleRowCount(4);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
add(new JScrollPane(list));

list.addListSelectionListener(
new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent event)
{
getContentPane().setBackground(colors[list.getSelectedIndex()]);

}
}
);
}

}

.................... Άλλη κλάση με όνομα  ColorsPanel.java .......................



import javax.swing.JFrame;

class RadioButton
{
public static void main(String[] args)
{

Gui go = new Gui();
go.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
go.setSize(300,200);
go.setVisible(true);


}
}

Εύρεση παραγοντικού με υποπρόγραμμα


public class paragontigo
{

//main
public static void main (String[] args)
{
System.out.println(fact(4));

}


//εύρεση παραγοντικού με υποπρόγραμμα
//υποπρόγραμμα
public static long fact(long n)
{
if(n<=1)
return 1;
else
return n * fact(n-1);
}
}

Τετάρτη 18 Απριλίου 2012

RadioButton

.......................................Ονομάζουμε την κλάση Gui.java..............................................

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Gui extends JFrame
{
private JTextField tf;
private Font pf;
private Font bf;
private Font itf;
private Font bif;
private JRadioButton pb;
private JRadioButton bb;
private JRadioButton ib;
private JRadioButton bib;
private ButtonGroup group;

public Gui ()
{
super("Kalpos Radio Button");
setLayout(new FlowLayout());

tf = new JTextField("Kalpos is the best programmer in the universe",25);
add(tf);

pb = new JRadioButton("plain",true);
bb = new JRadioButton("bold",false);
ib = new JRadioButton("italic",false);
bib = new JRadioButton("bold and italic",false);
add(pb);
add(bb);
add(bib);

group = new ButtonGroup();
group.add(pb);
group.add(bb);
group.add(ib);
group.add(bib);

pf = new Font("Serif", Font.PLAIN,14);
bf = new Font("Serif", Font.BOLD,14);
itf = new Font("Serif", Font.ITALIC,14);
bif = new Font("Serif", Font.BOLD + Font.ITALIC,14);
tf.setFont(pf);

//wait for event to happen, pass in font object to constructor
pb.addItemListener(new HandlerClass(pf));
bb.addItemListener(new HandlerClass(bf));
ib.addItemListener(new HandlerClass(itf));
bib.addItemListener(new HandlerClass(bif));
}


private class HandlerClass implements ItemListener
{
private Font font;

//the font object get variable font
public HandlerClass(Font f)
{
font = f;
}


//sets the font to the font object that was passed in
public void itemStateChanged(ItemEvent event)
{
tf.setFont(font);
}
}
}




.................... Άλλη κλάση με όνομα RadioButton.java .......................



import javax.swing.JFrame;

class RadioButton
{
public static void main(String[] args)
{

Gui go = new Gui();
go.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
go.setSize(300,200);
go.setVisible(true);


}
}


Παρασκευή 13 Απριλίου 2012

Πρόγραμμα δημιουργείας wordlist για netfaster router


/*Το πρόγραμμα δημιουργεί ένα αρχείο με επέκταση .txt με μια λίστα κωδικών για netfaster router που χρησιμοποιείται για να σπάσουμε δίκτυα Netfaster*/


#include <stdio.h>

int main(){
    char nu[6];
    printf("Enter the 6 last digits of BSSID 000559: ");
    scanf("%s", nu);   //Διαβαζει τα 6 τελευταία ψηφία του BSSID
    FILE *f;
    f = fopen("netfaster_wordlist.txt", "w");  // δημιουργια του αρχείου
    printf("Writing File Started\n");
    int i;
    for(i=0;i<=9999;i++)
    {
        if(i<10)
            fprintf(f, "000559%s-000%d\n", nu, i);
        else if(i<100)
            fprintf(f, "000559%s-00%d\n", nu, i);
        else if(i<1000)
            fprintf(f, "000559%s-0%d\n", nu, i);
        else
            fprintf(f, "000559%s-%d\n", nu, i);
        }
    fclose(f);
    printf("Writing file completed");
    getchar();
    return 0;
    }

Τετάρτη 11 Απριλίου 2012

Εμφάνιση παραθύρου YES/NO με ερώτηση (edited)


import javax.swing.JOptionPane;
public class Pinakas
{

    public static void main(String[] args)
    {
        if (JOptionPane.showConfirmDialog(null, "Είναι ο Παναθηναϊκός ο Αυτοκράτορας της Ευρώπης?","PAO BC", JOptionPane.YES_NO_OPTION)==0)
            JOptionPane.showMessageDialog(null, "Μπράβο είσαι Παναθηναϊκάρα!!!","Panathinaikos B.C.", JOptionPane.PLAIN_MESSAGE);
        else
             JOptionPane.showMessageDialog(null, "Άι στο διάολο κολόγαυρε ξαναπροσπάθησε","Panathinaikos B.C.", JOptionPane.PLAIN_MESSAGE);
    }
}

--------------EDIT BY tasosg4 15/4/2012 2:37------------------------------------------------------


Ουσιαστικά αυτό που θα γράψω είναι το ίδιο πράγμα απλά βάζω το confirm dialog σε μια ακέραια μεταβλητή x. Στο χ==1 θέλει else if αντί else γιατί με το else αν πατήσεις το Χ (Κλείσιμο) δεν κλείνει αμέσως η εφαρμογή αλλά σου βγάζει το μήνυμα που είναι για την απάντηση "ΝΟ".

import javax.swing.JOptionPane;  //vivliothiki gia to gui
public class Main {

    public static void main(String[] args) {
      int x = JOptionPane.showConfirmDialog(null, "yes or no","the title", JOptionPane.YES_NO_OPTION);

      if(x==0)
          JOptionPane.showMessageDialog(null, "You said YES", "the title", JOptionPane.PLAIN_MESSAGE);
      else if(x==1)
          JOptionPane.showMessageDialog(null, "You said NO", "the title", JOptionPane.PLAIN_MESSAGE);
    }
}


Danger Virus


import javax.swing.JOptionPane;
public class Virus
{

    public static void main(String args[])
    {
        JOptionPane.showMessageDialog(null, "DANGER  VIRUS!!!!!!!!", "title", JOptionPane.WARNING_MESSAGE);
    }
}

Age


public class Age
{
       public static void main(String args[])
       {
           if(args.length==1)
           {
               System.out.println("You are" + args[0]  + "years old");
           }
           else if (args.length==0)
               System.out.println("You forgot to give your age.");
           else
           {
               System.out.print(args[0] + " years old" + args[1] + "is");
           }
        }
}

Παραλλαγή της while....do με διάβασμα αριθμού για επανάληψη απτό πληκτρολόγιο

.text 0x00400000
####diavasma arithmou
   li $v0,5
   syscall
   move $t2,$v0
####bazo ston kataxoriti t1 thn timh 1
   li $t1,1

start:
#### emfanish tou mhnhmatos tou msg
   li $v0,4
   la $a0,msg
   syscall

#### prosthesi tou t1 me to 1 mexris otou o o t1<=t2
   add $t1,$t1,1
   ble $t1,$t2,start

#### exodos
   li $v0,10
   syscall


.data
   msg: .asciiz "\n my message"

Εναλλακτικός έλεγχος του αριθμού αν ανήκει στο [10,20]


.text 0x00400000

li $v0,4
la $a0,mes
syscall

li $v0,5
syscall
move $t1,$v0


bge $t1,10,syn
j termatismos
syn:
ble $t1,20,syn2
j termatismos

syn2:
li $v0,4
la $a0,msg
syscall

termatismos:

li $v0,10
syscall

.data

msg: .asciiz "$t1 anhkei sto [10,20]"
mes: .asciiz "doste arithmo:"

Έλεγχος του αριθμού αν ανήκει στο [10,20] (Assembly)


.text 0x00400000

li $v0,4
la $a0,mes
syscall

li $v0,5
syscall
move $t1,$v0


blt $t1,10,termatismos
bgt $t1,20,termatismos

li $v0,4
la $a0,msg
syscall

termatismos:

li $v0,10
syscall

.data

msg: .asciiz "$t1 anhkei sto [10,20]"
mes: .asciiz "doste arithmo:"

While...do (Assembly)

.text 0x00400000

li $t1,1

start:
ble $t1,15,loop
j termatismos
loop:
li $v0,4
la $a0,onoma
syscall

add $t1,$t1,1

j start

termatismos:
li $v0,10
syscall

.data

onoma: .asciiz "\n'Onoma' "

Do....While (Assembly)


.text 0x00400000

li $t1,1

start:
li $v0,4
la $a0,onoma
syscall

add $t1,$t1,1

ble $t1,15,start

li $v0,10
syscall

.data

onoma: .asciiz "\n'Onoma'"

Δευτέρα 9 Απριλίου 2012

Πρόσθεση δυο αριθμών με JAVA GUI



/*εμφανίζει δυο παράθυρα διαδοχικά στα οποία πρέπει να βάλουμε έναν αριθμό και στη συνέχεια σε ένα τρίτο παράθυρο εμφανίζεται το αποτέλεσμα*/

import javax.swing.JOptionPane; //vivliothiki gia to gui
public class Main {

    public static void main(String[] args) {
       String n1 = JOptionPane.showInputDialog("Enter the first number");
       /*apothikeuei auto pou eisagei o xristis sto parathiro se metavliti string*/
       String n2 = JOptionPane.showInputDialog("Enter the second number");

       float x = Float.parseFloat(n1); //μετατροπη του string n1 σε αριθμο
       float y = Float.parseFloat(n2); //μετατροπή του string n2 σε αριθμο
       float sum = x + y;
     
       //emfanizoume to apotelesma sto parathiro
       JOptionPane.showMessageDialog(null, "result: "+ sum, "result", JOptionPane.PLAIN_MESSAGE);
    }

}