#include <iostream.h>
int main ()
{
int vsota, deset_t, pet_t, tisoc, pet_s, dve_s, sto, pet_d, dvajset, deset, pet, ena;
char odg;
do
{
cout <<"vsota, ki jo zelite placati:"<<endl;
cin >>vsota;
if (vsota > 10000)
{
deset_t = vsota / 10000;
vsota = vsota % 10000;
cout <<"stevilo bankovcev po 10000 je "<<deset_t<<endl;
}
if (vsota > 5000)
{
pet_t = vsota / 5000;
vsota = vsota % 5000;
cout <<"stevilo bankovcev po 5000 je "<<pet_t<<endl;
}
if (vsota > 1000)
{
tisoc = vsota / 1000;
vsota = vsota % 1000;
cout <<"stevilo bankovcev po 1000 je "<<tisoc<<endl;
}
if (vsota > 500)
{
pet_s = vsota / 500;
vsota = vsota % 500;
cout <<"stevilo bankovcev po 500 je "<<pet_s<<endl;
}
if (vsota > 200)
{
dve_s = vsota / 200;
vsota = vsota % 200;
cout <<"stevilo bankovcev po 200 je "<<dve_s<<endl;
}
if (vsota > 100)
{
sto = vsota / 100;
vsota = vsota % 100;
cout <<"stevilo bankovcev po 100 je "<<sto<<endl;
}
if (vsota > 50)
{
pet_d = vsota / 50;
vsota = vsota % 50;
cout <<"stevilo bankovcev po 50 je "<<pet_d<<endl;
}
if (vsota > 20)
{
dvajset = vsota / 20;
vsota = vsota % 20;
cout <<"stevilo bankovcev po 20 je "<<dvajset<<endl;
}
if (vsota > 10)
{
deset = vsota / 10;
vsota = vsota % 10;
cout <<"stevilo bankovcev po 10 je "<<deset<<endl;
}
if (vsota > 5)
{
pet = vsota / 5;
vsota = vsota % 5;
cout <<"stevilo kovancev po 5 je "<<pet<<endl;
}
if (vsota > 1)
{
ena = vsota / 1;
cout <<"stevilo kovancev po 1 je "<<ena<<endl;
}
do
{
cout <<"Ali zelite nadaljevati (D/N)"<<endl;
cin >>odg;
}
while (odg != 'n' && odg !='d' && odg != 'N' && odg != 'D');
}
while (odg == 'D' || odg == 'd');
return 0;
}
|
Back to top
#include <windows.h> // windows header file
#include <stdio.h> // C standard library i/o header
#include <conio.h> // needed for getch()
#include <stdlib.h> // C standard library
//setcolor
//sets the default console color to 'color'
void setcolor(unsigned short color)
{
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon,color);
}
// main function
int main(int argc, char *argv[])
{
for(unsigned i = 0; i < 200; i++)
{
system("cls"); // clear the screen
setcolor(i); // changes the color
printf("color: %d\n", i); // prints the color ID
getchar(); // wait till a key is pressed
}
return 0;
}
|
Back to top
//**********************************
// * PROGRAM ZA IZRACUN NAJVECJEGA *
// * SKUPNEGA DELITELJA DVEH STEVIL *
// **********************************
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <windows.h>
void setcolor(unsigned short color)
{
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon,color);
}
int deli(int a, int b)
{
int st;
st = a;
while (st > 1)
{
if (a % st == 0)
if (b % st == 0)
break;
st --;
}
return st;
}
main()
{
char izbira;
setcolor(14);
int x, y, s;
cout << "\n **********************************";
cout << "\n * PROGRAM ZA IZRACUN NAJVECJEGA *";
cout << "\n * SKUPNEGA DELITELJA DVEH STEVIL *";
cout << "\n **********************************";
do
{
setcolor(11);
cout << "\n\n\n Vstavi prvo stevilo >>> ";
cin >> x;
cout << "\n Vstavi drugo stevilo >>> ";
cin >> y;
setcolor(10);
cout << "\n\n NAJVECJI skupni delitelj stevil " << x << " in " << y << " je stevilo "<< deli (x, y);
do
{
setcolor(14);
cout << "\n\n\n Za ponoven izracun pritisni d ali D, za izhod iz programa n ali N >>> ";
cin >> izbira;
}
while(izbira != 'n' && izbira !='N' && izbira != 'd' && izbira != 'D');
}
while (izbira == 'D' || izbira == 'd');
//if(izbira == 'n' || izbira == 'N')
system("cls");
setcolor(4);
cout << "\n\n\n\n\n\n\n\n\n\t ********* KONEC *********";
setcolor(14);
cout << "\n\n\n\n\n Pritisni tipko Enter za izhod iz programa >>> ";
getchar();
getchar();
return 0;
}
|
Back to top
/*
Ime programa: Elipsa, verzija 1.0
Avtor: Bojan Dreu, Leskovec 12 a, 2331 Pragersko
E-mail: my.3home.email@gmail.com
Opis: Program v C++, ki izracuna obseg in ploscino elipse.
Podatke za polosi vtipkamo preko tipkovnice, podatke in rezultate pa
izpise na zaslon.
Program resi poljubno stevilo nalog, ki so tudi ostevilcene.
Datum: September 2003
Vse pravice pridrzane: Bojan Dreu, 2003
*/
#include<stdio.h>
#include<stdlib.h>
main()
{
int stevec_nalog=1;
double PI = 3.14159265359;
float a, b;
double o, pl;
char odgovor;
do
{
system("cls");
printf(" ************************************************ ");
printf("\n * PROGRAM ZA IZRACUN OBSEGA IN PLOSCINE ELIPSE * ");
printf("\n *Avtor: Bojan Dreu, verzija 1.0, september 2003* ");
printf("\n ************************************************ ");
printf("\n\n\n Vnesi podatke za %d. elipso: ", stevec_nalog);
do
{
printf("\n\n Velika polos a: ");
scanf("%f",&a);
}
while(a <= 0);
do
{
printf("\n Mala polos b: ");
scanf("%f",&b);
}
while(b <=0);
printf("\n\n REZULTATI %d. ELIPSE: ", stevec_nalog);
printf("\n\n Velika polos a = %g ", a);
printf("\n\n Mala polos b = %g ", b);
o = PI * (a + b);
pl = PI * a * b;
printf("\n\n Obseg = %.5g ", o);
printf("\n\n Ploscina = %.5g ", pl);
stevec_nalog++;
do
{
printf("\n\n\n Zelis izracunat se eno nalogo ( d ali D / n ali N ) ? >>> ");
scanf("%s", &odgovor);
}
while(odgovor != 'n' && odgovor !='N' && odgovor != 'd' && odgovor != 'D');
}
while (odgovor == 'd' || odgovor == 'D');
system("cls");
printf("\n\n\n\n\n\n\n\n\n\t ***** K O N E C ***** ");
printf("\n\n\n\n Za izhod iz programa pritisni tipko [Enter] >>>>> ");
getchar();
getchar();
return(0);
}
|
Back to top
/* IZ3_ENG.cpp: Program for calculating round and area of triangel */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <iostream.h>
#include <time.h>
#define SIZE 256
main()
{
FILE *vhod;
char vhodna[80];
float a, b, c;
float o, s, P;
putchar('\n');
printf("\t\t A\n");
printf("\t\t *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * II ZZZZZ 33333 *\n");
printf("\t\t b * II Z 3 * c\n");
printf("\t\t * II ZZZ 3 *\n");
printf("\t\t * II Z 3 3 *\n");
printf("\t\t * II ZZZZZ 333 *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * *\n");
printf("\t\t * a *\n");
printf("\t\tC *********************************************** B ");
getchar();
char buffer[SIZE];
time_t curtime;
struct tm *loctime;
curtime = time (NULL);
loctime = localtime (&curtime);
printf("\n\n\n\n\n\n\n\n\n\n\n\t\t\t Hello !!!");
strftime (buffer, SIZE, "\n\n\n\n\n\t\t Tuday is %d.%m.%Y, time is %H in %M minits.\n", loctime);
fputs (buffer, stdout);
printf("\n\n\n\n\n\n\n\n\t I WISH YOU MANY ACCES by using program IZ3 !");
getchar();
{
system("cls");
printf("\n\n\t\t=======================================================\n");
printf("\t\t| ***** IZ3 ***** |\n");
printf("\t\t| PROGRAM FOR CALCULATING ROUND AND AREA OF TRIANGLE |\n");
printf("\t\t| Version 1.2, february 2003 |\n");
printf("\t\t| |\n");
printf("\t\t| Autor: Bojan Dreu, Leskovec 12, 2331 Pragersko, SLO |\n");
printf("\t\t| E-mail: dr.eu@email.si |\n");
printf("\t\t=======================================================\n\n");
printf("\t\t PROGRAM FROM INPUT DATA IN INPUT FILE CALCULATE:\n\n");
printf("\t\t\t - R O U N D OF TRIANGEL\n\n");
printf("\t\t\t\t\t and\n\n");
printf("\t\t\t - A R E A OF TRIANGEL\n\n");
printf("\t\t---------------------------------------------------------\n");
getchar();
}
{
system("cls");
cout << "\n\n Data on input file, which must be in format txt, ";
cout << "\n must be writen like this: a b c ";
cout << "\n\n\t for example: 6.592 7.008 2.375 ";
cout << "\n\t or: 3. 9 5. ";
cout << "\n\t or: 2 8.3 6 ";
cout << "\n\n Input file can't include characters !!! ";
cout << "\n\n\n Enter path, name and format of input file:\n\n ";
cout << " Enter >>> ";
cin>>vhodna;
}
vhod= fopen(vhodna,"r");
if(vhod == NULL)
{
system("cls");
cout << "\a\n\n\n\n\n\n\n You tipe name of input file >>> " << vhodna << " . \n";
cout << "\n\n\n\n\n CAN'T OPEN THIS FILE, BEACUSE DONT EXISTE !!! ";
cout << "\n\n\n\n\n\n\n\t ********** END OF PROGRAM ********** ";
cout << "\n\n\n\n\n\t For exit type [Enter] >>> ";
getchar();
exit(0);
}
int stevec_trikotnikov = 0;
int stevec=0;
int count;
//while (fscanf(vhod, "%f %f %f",&a, &b, &c) != EOF)
while ((count = fscanf(vhod, "%f %f %f",&a, &b, &c)) != EOF)
{
if(count < 3)
{
stevec++;
char bad;
fscanf(vhod, "%c", &bad);
printf("Error in data: %c\n", bad);
printf("Data in %d. line are wrong !",stevec);
getchar();
}
else
{
o= a + b + c;
s= (a + b + c) / 2.0;
P = sqrt(s * ((s - a) * (s - b) * (s - c)));
stevec_trikotnikov++;
system("cls");
printf("\n\n DATA SIDES OF %d. TRIANGEL:\n", stevec_trikotnikov);
printf(" -------------------------------------------------------\n\n");
printf(" Side a = %5.3f m\n", a);
printf(" Side b = %5.3f m\n", b);
printf(" Side c = %5.3f m\n", c);
printf(" -------------------------------------------------------\n");
if(a <= 0 )
{
printf(" Wrong data of side a !\n");
}
if(b <= 0 )
{
printf(" Wrong data of side b !\n");
}
if(c <=0 )
{
printf(" Wrong data of side c !\n");
}
printf("\n\n RESULTS:\n");
printf(" -------------------------------------------------------\n");
if( a <= 0 || b <= 0 || c <= 0)
{
printf("\n ROUND of %d. triangle IS NOT POSSIBILE TO CALCULATE !!!", stevec_trikotnikov);
}
if(s <= a || s <= b || s<= c)
{
printf("\n AREA of %d. triangle IS NOT POSSIBILE TO CALCULATE !!!\n", stevec_trikotnikov);
printf(" =======================================================)\n");
printf(" For next triangle type Enter --> ");
getchar();
}
else
{
printf("\n ROUND of %d. triangle is: %5.3f m.\n\n", stevec_trikotnikov, o);
printf(" AREA of %d. triangle is: %5.3f m2.\n", stevec_trikotnikov, P);
printf(" =======================================================\n");
printf(" For next triangle type Enter --> ");
getchar ();
}
}
}
printf("\n\n\n\n\n\n\n\n\n\n\t\t ** NO MORE DATA IN INPUT FILE !! **\n\n\n\n\n\n");
fclose(vhod);
cout << "\n\n\n\n\n\n\n\n\n\n"<<"\t\t ********** END OF PROGRAM ********** ";
cout << "\n\n\n \t\t For exit type [Enter] >>> ";
getchar();
return 0;
}
|
Back to top
//Tic Tac Toe
//Krizci in krozci
//Prevedel Bojan Dreu
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
char matrix[3][3];//={0};
void cou(void);
int main()
{
int m,n;
char ch='y';
while(ch=='Y'||ch=='y'){
for (m=0;m<3;m++)for (n=0;n<3;n++)matrix[m][n]= '\0';
int i,j,sum=0;
while ( sum < 10){
if (sum == 0) cou();
cout<<"\nIgralec 1 ima 'X': izberi vrstico in stolpec"<<endl;
cout<<"Vrstica : ";
cin>>i;
cout<<"Stolpec : ";
cin>>j;
for (;i>3 || i<1 || j>3 || j<1 ||('X'==matrix[i-1][j-1]||'O'==matrix[i-1][j-1]);)
{
cout<<"\nOprosti fant, toda moral bos izbrati drugo pozicijo.\n";
cout<<"Vrstica : ";cin>>i;
cout<<"Stolpec : ";cin>>j;
}
matrix[i-1][j-1]='X';
sum++;
cou();
//Preveri zmago
if (matrix[0][0]=='X' && matrix[0][0]==matrix[1][1] && matrix[1][1]==matrix[2][2]) {cout<<"\nIgralec 1 je zmagal !"<<endl;break;}
if (matrix[2][0]=='X' && matrix[2][0]==matrix[1][1] && matrix[1][1]==matrix[0][2]) {cout<<"\nIgralec 1 je zmagal !"<<endl;break;}
if (matrix[0][0]=='X' && matrix[0][0]==matrix[1][0] && matrix[1][0]==matrix[2][0]) {cout<<"\nIgralec 1 je zmagal !"<<endl;break;}
if (matrix[0][1]=='X' && matrix[0][1]==matrix[1][1] && matrix[1][1]==matrix[2][1]) {cout<<"\nIgralec 1 je zmagal !"<<endl;break;}
if (matrix[0][2]=='X' && matrix[0][2]==matrix[1][2] && matrix[1][2]==matrix[2][2]) {cout<<"\nIgralec 1 je zmagal !"<<endl;break;}
if (matrix[0][0]=='X' && matrix[0][0]==matrix[0][1] && matrix[0][1]==matrix[0][2]) {cout<<"\nIgralec 1 je zmagal !"<<endl;break;}
if (matrix[1][0]=='X' && matrix[1][0]==matrix[1][1] && matrix[1][1]==matrix[1][2]) {cout<<"\nIgralec 1 je zmagal !"<<endl;break;}
if (matrix[2][0]=='X' && matrix[2][0]==matrix[2][1] && matrix[2][1]==matrix[2][2]) {cout<<"\nIgralec 1 je zmagal !"<<endl;break;}
if (sum == 9)
{
cout<<"\nIgre je konec in nobeden ni zmagal, ha, ha, ha, oba smrdita !!!"<<endl; break;
} //sum=9 ker je samo 9 monih pozicij v igri
//Na vrsti je drugi igralec
cout<<"\nIgralec 2 ima 'O': izberi vrstico in stolpec"<<endl;
cout<<"Vrstica : ";
cin>>i;
cout<<"Stolpec : ";
cin>>j;
for (;i>3 || i<1 || j>3 || j<1 ||('X'==matrix[i-1][j-1]||'O'==matrix[i-1][j-1]);)
{
cout<<"Oprosti fant, toda moral bos izbrati drugo pozicijo.\n";
cout<<"Vrstica : ";
cin>>i;
cout<<"Stolpec : ";
cin>>j;}
matrix[i-1][j-1]='O';
sum++;
//Igralna ploskev
cou();
//Preveri zmago
if (matrix[0][0]=='O' && matrix[0][0]==matrix[1][1] && matrix[1][1]==matrix[2][2]) {cout<<"Igralec 2 je zmagal !"<<endl;break;}
if (matrix[2][0]=='O' && matrix[2][0]==matrix[1][1] && matrix[1][1]==matrix[0][2]) {cout<<"Igralec 2 je zmagal !"<<endl;break;}
if (matrix[0][0]=='O' && matrix[0][0]==matrix[1][0] && matrix[1][0]==matrix[2][0]) {cout<<"Igralec 2 je zmagal !"<<endl;break;}
if (matrix[0][1]=='O' && matrix[0][1]==matrix[1][1] && matrix[1][1]==matrix[2][1]) {cout<<"Igralec 2 je zmagal !"<<endl;break;}
if (matrix[0][2]=='O' && matrix[0][2]==matrix[1][2] && matrix[1][2]==matrix[2][2]) {cout<<"Igralec 2 je zmagal !"<<endl;break;}
if (matrix[0][0]=='O' && matrix[0][0]==matrix[0][1] && matrix[0][1]==matrix[0][2]) {cout<<"Igralec 2 je zmagal !"<<endl;break;}
if (matrix[1][0]=='O' && matrix[1][0]==matrix[1][1] && matrix[1][1]==matrix[1][2]) {cout<<"Igralec 2 je zmagal !"<<endl;break;}
if (matrix[2][0]=='O' && matrix[2][0]==matrix[2][1] && matrix[2][1]==matrix[2][2]) {cout<<"Igralec 2 je zmagal !"<<endl;break;}
}
cout<<"\n\n\nBi rada igrala se enkrat ??? (Y - N) ";
cin>>ch;
}
// system("PAUSE"); //odstranil
return 0;
}
void cou(void)
{
//Igralna ploskev
system("cls"); //dodal
cout<<"\n\t\t ************************ "; //dodal
cout<<"\n\t\t * KRIZCI IN KROZCI *"; //dodal
cout<<"\n\t\t * Prevedel: Bojan Dreu *"; //dodal
cout<<"\n\t\t ************************\n\n\n\n"; //dodal
cout<<"\t\t 1 2 3\n"<<endl;
cout<<"\t\t 1 "<<matrix[0][0]<<" | "<<matrix[0][1]<<" | "<<matrix[0][2]<<endl;
cout<<"\t\t ---|---|---\n";
cout<<"\t\t 2 "<<matrix[1][0]<<" | "<<matrix[1][1]<<" | "<<matrix[1][2]<<endl;
cout<<"\t\t ---|---|---\n";
cout<<"\t\t 3 "<<matrix[2][0]<<" | "<<matrix[2][1]<<" | "<<matrix[2][2]<<"\n\n\n";
}
|
Back to top
/*
Poraba.exe - Poraba_goriva.cpp, verzija 2.0, april 2005 - IZRACUN PORABE GORIVA
Program izracuna porabo goriva avtomobila.
Podatke (datum tocenja, prevozene kilometre, natocene litre goriva, ceno goriva) in
rezultate (znesek placila, porabo goriva na 100 km) nam izpise na zaslon in
v poljubno imenovano izhodno datoteke tipa TXT.
Avtor: Bojan Dreu
Naslov: Leskovec 12 a, 2331 Pragersko, SLO
E-mail: my.3home.email@gmail.com
Internet: http://cpp-beginner.50webs.com
Datum: 23.04.2005
*/
#include <iostream>
#include <stdio.h>
#include <windows.h>
using namespace std;
/* Funkcija Barva_pisave() - funkcija za dolocitev barve izpisanega teksta na zaslonu */
void Barva_pisave(unsigned short color)
{
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon,color);
}
/* Funkcija Meni() - funkcija za izpis izbirnega menija */
void Meni()
{
Barva_pisave(10); //barva teksta
cout << "\n\n\n\t IZBIRNI MENI: \n\n"; //izpis izbirnega menija za podatke
cout << "\t 0 - IZHOD iz programa \n";
cout << "\t 1 - POMOC \n";
cout << "\t 2 - IZRACUN porabe goriva \n";
cout << "\t ======================================================= \n";
Barva_pisave(14); //barva teksta
cout << "\t Vpisi stevilko izbire in pritisni tipko [Enter] >>> ";
}
/* Funkcija Opozorilo() - funkcija za izpis opozorila na zaslon pri napacni izbiri iz menija */
void Opozorilo()
{
system("cls"); //brisanje zaslona
Barva_pisave(4); //barva teksta
cout << "\a\n\n\t\t * * * * * * * \n"; //izpis opozorila ob napacni izbiri iz menija
cout << "\t\t * * \n";
cout << "\t\t * * \n";
cout << "\t\t * * \n";
cout << "\t\t * * \n";
cout << "\t\t * O P O Z O R I L O !!! * \n";
cout << "\t\t * * \n";
cout << "\t\t * Taksna izbira ni mozna !! * \n";
cout << "\t\t * * \n";
cout << "\t\t * Poskusi ponovno ! * \n";
cout << "\t\t * * \n";
cout << "\t\t * * \n";
cout << "\t\t * * \n";
cout << "\t\t * * \n";
cout << "\t\t * * * * * * * \n";
}
/* Funkcija Pomoc() - funkcija za izpis pomoci pri programu */
void Pomoc()
{
system("cls"); //brisanje zaslona
Barva_pisave(12); //barva teksta
cout << " **************************************************************** \n"; //izpis pomoci za program
cout << " * P O M O C * \n";
cout << " * za program Poraba.exe, verzija 2.0, april 2005 * \n";
cout << " **************************************************************** \n\n\n";
Barva_pisave(3); //barva teksta
cout << " Program nam izracuna porabo goriva avtomobila.\n";
cout << " Vnesemo datum, ko smo natocili gorivo, \n";
cout << " koliko kilometrov smo prevozili, \n";
cout << " koliko goriva smo natocili \n";
cout << " in ceno za liter goriva. \n\n";
cout << " Nato nam program izracuna: \n\n";
cout << " - skupni znesek za placilo goriva. \n";
cout << " - porabo goriva na 100 kilometrov. \n\n";
cout << " Program nam nato izpise vse vhodne podatke in rezultate \n";
cout << " na zaslon in v poljubno imenovano izhodno datoteko tipa TXT. \n\n";
cout << " Ce datoteka ze obstoja, podatke in rezultat zapise na konec \n";
cout << " te datoteke, drugace pa ustvari novo. \n";
Barva_pisave(14); //barva teksta
cout << "\n\n Za nadaljevanje pritisni tipko [Enter] >>> ";
cin.ignore();
cin.ignore();
system("cls"); //brisanje zaslona
Barva_pisave(12); //barva teksta
cout << "\n VNOS PODATKOV: ";
Barva_pisave(3); //barva teksta
cout << "\n\n\n Pri vnosu decimalnih stevil moramo uporabljati decimalno piko. ";
cout << "\n\n Datum, ko smo natocili gorivo, ";
cout << "\n vtipkamo na primer: 09.04.2005 ";
cout << "\n\n Stevilo prevozenih kilometrov, ";
cout << "\n vtipkamo na primer: 523.8 ali 489. ali 601 ";
cout << "\n\n Stevilo natocenih litrov goriva, ";
cout << "\n vtipkamo na primer: 23.8 ali 48. ali 51 ";
cout << "\n\n Cena za liter goriva, ";
cout << "\n vtipkamo na primer: 201.25 ali 205. ali 220 ";
Barva_pisave(4); //barva teksta
cout << "\n\n\n\n\t VTIPKANI PODATKI NE SMEJO BITI CRKE !!! ";
Barva_pisave(14); //barva teksta
cout << "\n\n\n\n Za nadaljevanje pritisni tipko [Enter] >>> ";
cin.ignore();
system("cls"); //brisanje zaslona
Barva_pisave(12); //barva teksta
cout << "\n NAPAKE, OPOZORILA ";
Barva_pisave(3); //barva teksta
cout << "\n\n\n Program nam izpise vse vhodne podatke in rezultate ";
cout << "\n v poljubno imenovano izhodno datoteko tipa TXT. ";
cout << "\n\n\n Ce ne navedemo prave obstojece poti za izhodno datoteko, ";
cout << "\n nam program po zvocnem signalu javi, da te datoteke ne more ustvariti. ";
cout << "\n\n Ce za izhodno datoteko ne navedemo poti in tipa datoteke, jo bo ";
cout << "\n program brez tipa datoteke shranil tja, kjer se nahaja program Poraba.exe. ";
cout << "\n\n To izhodno datoteko lahko kasneje spremenimo v TXT tip datoteke ";
cout << "\n in tako lahko pridemo do zapisanih podatkov in rezultatov. ";
Barva_pisave(14); //barva teksta
cout << "\n\n\n\n\n\n\n\n\n Za nadaljevanje pritisni tipko [Enter] >>> ";
cin.ignore();
system("cls"); //brisanje zaslona
Barva_pisave(12); //barva teksta
cout << "\n IZPIS PODATKOV IN REZULTATOV ";
Barva_pisave(3); //barva teksta
cout << "\n\n\n Podatke in rezultate program izpise na zaslon ";
cout << "\n in v poljubno izhodno datoteko tipa TXT ";
cout << "\n v naslednji obliki: ";
cout << "\n\n Datum : 09.04.2005 ";
cout << "\n\n Stevilo prevozenih km : 523.8 ";
cout << "\n\n Stevilo natocenih litrov goriva : 48. ";
cout << "\n\n Cena za liter goriva : 201.25 ";
cout << "\n\n\n Za placilo: 9660.00 SIT";
cout << "\n\n\n Poraba goriva na 100 km je : 9.16 L";
cout << "\n\n *********************************************** ";
Barva_pisave(14); //barva teksta
cout << "\n\n Za izhod iz pomoci pritisni tipko [Enter] >>> ";
}
/* Glavna funkcija() */
int main ()
{
char izbor;
char datum[11];
float kilometri, litri, cena;
double znesek;
double poraba;
Barva_pisave(11);
cout << "\n\n\n\t *******************************************************";
cout << "\n\t * P O R A B A *";
cout << "\n\t * PROGRAM ZA IZRACUN PORABE GORIVA AVTOMOBILA *";
cout << "\n\t * Verzija 2.0 , april 2005 *";
cout << "\n\t * Avtor: Bojan Dreu, Leskovec 12, 2331 Pragersko, SLO *";
cout << "\n\t *******************************************************";
Meni();
cin >> izbor; //preberi vtipkani izbor za meni
while(izbor != '0') //dokler je vtipkan znak razlicen od 0
{
switch(izbor) //vklopi izbiro
{
case'1': //v primeru vtipkanega znaka 1 (Pomoc)
{
Pomoc();//izpis pomoi za program
cin.ignore();
system("cls"); //brisanje zaslona
break;
}
case'2': //v primeru vtipkanega znaka 2 (izraun porabe)
{
system("cls");
Barva_pisave(3);
cout <<"\n Datum : ";
cin >>datum;
cout <<"\n\n Stevilo prevozenih km : ";
cin >>kilometri;
cout <<"\n\n Stevilo natocenih litrov goriva : ";
cin >>litri;
cout <<"\n\n Cena za liter goriva SIT : ";
cin >>cena;
znesek = cena * litri;
Barva_pisave(10);
cout <<"\n\n\n Za placilo : " << znesek << " SIT ";
poraba = (litri * 100) / kilometri;
Barva_pisave(10);
printf("\n\n\n Poraba goriva na 100 km je %.2f L", poraba);
Barva_pisave(8);
printf("\n\n ***************************************************************** ");
FILE *izhod;
char izhodna[80];
do
{
Barva_pisave(14);
cout << "\n\n\n Vtipkaj ime in tip izhodne datoteke (txt) ter celotno pot do nje: \n\n";
cout << " vnos >>> ";
cin >> izhodna;
izhod = fopen(izhodna, "a");// odpiranje izhodne datoteke in dodajanje, ce ze obstaja
system("cls");
Barva_pisave(6);
cout << "\a\n\n\n\n\n\n\n Vtipkal si ime datoteke za zapis rezultatov >>> " << izhodna << " !!! \n";
Barva_pisave(4);
cout << "\n\n\n\n\n\t PODANE IZHODNE DATOTEKE NE MOREM USTVARITI !!! ";//izpise napako
}while(izhod == NULL); // neuspesno odpiranje izhodne datoteke
fprintf(izhod, "\n Datum : %s", datum);
fprintf(izhod, "\n\n Stevilo prevozenih km : %.2f", kilometri);
fprintf(izhod, "\n\n Stevilo natocenih litrov goriva : %.2f", litri) ;
fprintf(izhod, "\n\n Cena za liter goriva : %.2f SIT", cena);
fprintf(izhod, "\n\n\n Za plailo: %.2f SIT", znesek);
fprintf(izhod, "\n\n\n Poraba goriva na 100 km je : %.2f L", poraba);
fprintf(izhod, "\n\n ************************************************\n\n\n");
fclose(izhod);
system ("cls");
Barva_pisave(4);
cout << "\n\n\n\n\n\n\n\n\n\n\n\t\t ********** KONEC PROGRAMA ********** \n\n\n\n\n\n\n\n";
Barva_pisave(14);
cout << "\t\t Za izhod iz programa pritisni tipko [Enter] >>> ";
cin.ignore();
cin.ignore();
return 0; //izhod iz programa
}
default: //v primeru izbire druganega znaka od 0, 1, 2 ali 3
{
Opozorilo(); //izpis opozorila ob napani izbiri
break;
}
}
Barva_pisave(10); //barva teksta
Meni(); //izpie meni
cin >> izbor; //preberi izbiro za meni
}
system("cls"); //brisanje zaslona
Barva_pisave(4); //barva teksta
cout << "\n\n\n\n\n\n\n\n\n\n\t\t ********** KONEC PROGRAMA ********** "; //obvestilo o koncu programa
Barva_pisave(14); //barva teksta
cout << "\n\n\n\n\n\n\n\t\t Za izhod iz programa pritisni tipko [Enter] >>> ";
cin.ignore();
cin.ignore();
return(0); //izhod iz programa
}
|
Back to top
/*
Ime programa: SIT2EUR.exe, verzija 1.0
Avtor: Bojan Dreu, Leskovec 12 a, 2331 Pragersko
E-mail: my.3home.email@gmail.com
Opis: Program v C++, ki preracuna SIT v EURE in obratno
Znesek vtipkamo preko tipkovnice, podatke in rezultate pa
izpise na zaslon.
Datum: Maj 2006
Vse pravice pridrzane: Bojan Dreu, 2006
*/
#include<stdio.h>
#include<stdlib.h>
main()
{
int izbira;
float SIT, EUR;
char odgovor;
do
{
system("cls");
printf("\n **********************************************");
printf("\n * PROGRAM ZA PRERACUN SIT v EUR (in obratno) *");
printf("\n * Avtor: Bojan Dreu, SLO *");
printf("\n * Verzija 1.0, maj 2006 *");
printf("\n **********************************************");
printf("\n\n\n\n\n\n\n Ce zelis preracunati tolarje v eure pritisni 1, ");
printf("\n\n\n ce pa zelis preracunati eure v tolarje, pritisni 2. ");
printf("\n\n\n\n\n\n\n Vtipkaj izbrani preracun >>> ");
scanf("%d", & izbira);
switch (izbira)
{
case 1:
system("cls");
printf("\n\n\n\n Vpisi znesek tolarjev: ");
scanf("%f", & SIT);
EUR = SIT / 239.64;//bilo je 226.87;
printf("\n\n\n\n\n %.2f tolarjev je %.2f eurov. ", SIT, EUR);
break;
case 2:
system("cls");
printf("\n\n\n\n\n Vpisi znesek eurov: ");
scanf("%f", & EUR);
SIT = EUR * 239.64;//bilo je 226.87;
printf("\n\n\n\n\n %.2f eurov je %.2f tolarjev. ", EUR, SIT);
break;
default:
system("cls");
printf("\n\n\n\n\n Vpisal si NAPACNO IZBIRO !!!\n");
}
do
{
printf("\n\n\n\n\n\n\n\n\n Zelis opraviti se en preracun?");
printf("\n\n ( d ali D za DA, n ali N za NE) >>> ");
scanf("%s", &odgovor);
}
while(odgovor != 'n' && odgovor !='N' && odgovor != 'd' && odgovor != 'D');
}
while (odgovor == 'd' || odgovor == 'D');
system("cls");
printf("\n\n\n\n\n\n\n\n\n ********* K O N E C ********* ");
printf("\n\n\n\n\n\n\n\n\n Za izhod iz programa pritisni tipko [Enter] >>>>> ");
getchar();
getchar();
return (0);
}
|
Back to top
#include <stdio.h>
#include <malloc.h>
#include <time.h>
#define TEST(f,x) (*(f+(x)/16)&(1<<(((x)%16L)/2)))
#define SET(f,x) *(f+(x)/16)|=1<<(((x)%16L)/2)
int
main(int argc, char *argv[])
{
unsigned char *feld=NULL, *zzz;
unsigned long teste=1, max, mom, hits=1, count, alloc, s=0, e=1;
time_t begin;
if (argc > 1)
max = atol (argv[1]) + 10000;
else
max = 14010000L;
while (feld==NULL)
zzz = feld = malloc (alloc=(((max-=10000L)>>4)+1L));
for (count=0; count<alloc; count++) *zzz++ = 0x00;
printf ("Searching prime numbers to : %ld\n", max);
begin = time (NULL);
while ((teste+=2) < max)
if (!TEST(feld, teste)) {
if (++hits%2000L==0) {printf (" %ld. prime number\x0d", hits); fflush(stdout);}
for (mom=3L*teste; mom<max; mom+=teste<<1) SET (feld, mom);
}
printf (" %ld prime numbers foundn %ld secs.\n\nShow prime numbers",
hits, time(NULL)-begin);
while (s<e) {
printf ("\n\nStart of Area : "); fflush (stdout); scanf ("%ld", &s);
printf ("End of Area : "); fflush (stdout); scanf ("%ld", &e);
count=s-2; if (s%2==0) count++;
while ((count+=2)<e) if (!TEST(feld,count)) printf ("%ld\t", count);
}
free (feld);
return 0;
}
|
Back to top
// Author: Inder Mohan Singh
// Project Name: Simple Board Game (oop concept)
// Number of Files: 3
// Files Name: Board.cpp, game.cpp, board.h
/* Code provided by Author Inder Mohan Singh (http://www.geocities.com/imsb69) 'as is',
without warranties as to performance, fitness, <br>merchantability,and any other warranty
(whether expressed or implied ).Terms of Agreement: By using this source code, you agree
to the following terms...
1) You may use this source code in personal projects and may compile it into an
.exe/.dll/.ocx and distribute it in binary format freely and with no charge.
2) You MAY NOT redistribute this source code (for example to a web site) without
written permission from the original author.Failure to do so is a violation of copyright
laws.
3) You may link to this code from another website, provided it is not wrapped in a frame.
If you find any bug in this source codes please e-mail imsb69@yahoo.com
*/
#include <iostream.h>
#include <conio.h>
#include "board1.h"
#include <stdio.h> //dodal
void main(void)
{
Game game;
game.play();
getchar();
}
|
// define the different class for simple board game
const int MAX_ROWS = 9; // Maximum rows
const int MAX_COLUMNS = 9; // Maximum columns
const int WINNING_LINE = 4;
const int NUM_PLAYERS = 2; // Maximum numbers of players is 4
const int DEFAULT_ROWS = 6; // Default numbers of rows
const int DEFAULT_COLUMNS = 7; // Default numbers of columns
enum Boolean {False , True };
enum BoardState {DRAW, WIN, PLAY};
const char INVISIBLE = ' ';
const int SELECT_REPRESENTATION = 1;
// Used to represent a counter that will be dropped into column on the gaming
// board
class Counter
{
private:
static int tokenNum; // which token to allocate
char theToken; // the token used as the counter
public:
static void setTokenNum();
Counter();
Counter( const char);
Counter (const int);
~Counter() {}
char token() const; // returns the characters
void display () const; // display the character to screen
};
// represent a game player, makes move and announces win or draw
class Player
{
private:
Counter thePlayersCounter;
public:
Player (); // constructor assigns a token for the player
~Player() { } // destructor
int getMove(const Boolean ) const; // Ask for a move
Counter getCounter () const; // Get a counter
void announce(const BoardState)const; // allows the player to announce the win or draw
};
// represent the individual cell in the gaming board
class Cell
{
private:
Counter theCounter; // the counter in this cell
public:
Cell(); // sets the cel to contain the space ' ' character
~Cell() {} // destructor
void clear(); // clear the cell to place space character ' '.
void drop (const Counter); // drops the counter in the cell
char holds()const; // report back the token representation of the counter
void display()const; // request the counter to display itself
};
//The gaming board which which appears on the computer
class Board
{
private:
Cell grid[MAX_ROWS][MAX_COLUMNS]; //playing board made up of cells
int height[MAX_COLUMNS]; // current height of counters col
int rowSize;
int columnSize; // size of the playing area
int lastRow; // row of the last counter
int lastCol; // col of the last counter
int numEmptyCells; // remaining empty cell
protected:
int checkForWin ( const int ,const int ,const int, const char )const;
void addCounterToBoard (const int,const Counter);
Boolean isThereAWin()const ; // check for a win
public:
// constructor default size 6 x 7
Board (const int rows =DEFAULT_ROWS,const int columns = DEFAULT_COLUMNS);
~Board() { } // destructor
// reset the game for new game
void reset (const int rows =DEFAULT_ROWS,const int columns = DEFAULT_COLUMNS);
void dropInColumn (const int,const Counter ); // drop the counter in the column
Boolean moveOkForColumn (const int) const; // check for valid col number and
// col is not full
void display()const; // draw the board
BoardState situation()const; // reports the state of the game
};
// Co-ordinate Board Game
class Game
{
private: // the playing board
Board board;
BoardState state;
Player contestant[NUM_PLAYERS]; // holds the number of player
int num;
public:
Game();
~Game(){} // destructor
void play (); // controls the game play until the state of the game
// changes
};
// end of board.h
|
// definition of members method of all the classes
#include <iostream.h>
#include <conio.h>
#include <stdio.h> //dodal
#include <stdlib.h> //dodal
#include "board1.h"
int Counter::tokenNum ; // allocate storage to the static
// sets the representational token to invisible
void Counter:: setTokenNum()
{
tokenNum = 0;
}
// sets the representational token to the one requested
inline Counter::Counter()
{
theToken = INVISIBLE;
}
// dummy parameter to distinguish constructor
Counter::Counter(const int)
{ // Subscripting operator used to deliver a token to use asa counter
theToken = "XO$#"[tokenNum++];
}
Counter::Counter(const char representation)
{
theToken = representation;
}
inline char Counter::token() const
{
return theToken;
}
inline void Counter::display() const
{
cout << theToken;
}
// assigns the token for the player
Player::Player()
{
thePlayersCounter = Counter (SELECT_REPRESENTATION);
}
int Player::getMove(const Boolean first) const
{
int move;
if (first != True)
cout << "\nNAPAKA -- Napacna izbira " << endl;
cout << "\nPoteza za igralca " << thePlayersCounter.token() << " je ";
cin >> move;
return move -1;
}
inline Counter Player::getCounter() const
{
return thePlayersCounter;
}
void Player::announce(const BoardState what) const
{
cout << "\n\n\nIgralec " << thePlayersCounter.token();
switch (what)
{
case WIN : cout << " je ZMAGAL !" << endl;
break;
case DRAW : cout << " - konec igre - plosca je polna !" << endl;
break;
}
cout << "\n\nPritisni tipko [Enter] za izhod >>> "; //dodal
}
Cell::Cell()
{
theCounter = Counter(INVISIBLE);
}
inline void Cell:: clear()
{
theCounter = Counter(INVISIBLE);
}
inline void Cell:: drop(const Counter c)
{
theCounter = c;
}
inline char Cell::holds() const
{
return theCounter.token();
}
inline void Cell::display() const
{
theCounter.display();
}
Board::Board (const int rows,const int columns)
{
reset(rows, columns);
}
void Board::reset(const int rows,const int columns)
{
rowSize= rows;
columnSize= columns;
for (int i = 0; i < columnSize; i++)
{
for (int j =0; j < rowSize; j++)
grid[j][i].clear();
height[i] = 0;
}
lastRow=lastCol = 0;
numEmptyCells = rows*columns;
}
void Board::dropInColumn (const int column, const Counter c)
{
lastCol = column;
lastRow=height[column];
addCounterToBoard(column, c);
}
Boolean Board::moveOkForColumn (const int column) const
{
if (column >= 0 && column < columnSize)
if (height[column] < rowSize)
return True;
return False;
}
void Board:: addCounterToBoard(const int column, const Counter playersCounter)
{
grid[height[column]] [column].drop(playersCounter);
height[column]++;
numEmptyCells--;
}
BoardState Board::situation() const
{
if (isThereAWin() == True)
return WIN;
if (numEmptyCells == 0)
return DRAW;
return PLAY;
}
Boolean Board::isThereAWin() const
{
char counter = grid[lastRow][lastCol].holds();
for (int direction = 1; direction <=4; direction++)
{
int countersInaLine = checkForWin(direction, lastRow, lastCol, counter)
+ checkForWin(direction + 4, lastRow, lastCol, counter) - 1;
if(countersInaLine >= WINNING_LINE)
return True;
}
return False;
}
int Board:: checkForWin(const int direction, const int xCord, const int yCord,
const char counter) const
{
int x = xCord;
int y = yCord;
if (( x >=0 && x < rowSize) && (y >=0 && y < columnSize)
&& (grid[x][y].holds() == counter))
{
switch(direction)
{
case 1: y++; break;
case 2: x++; y++; break;
case 3: x++; break;
case 4: x++; y--; break;
case 5: y--; break;
case 6: x--; y--; break;
case 7: x--; break;
case 8: x--; y++; break;
default: cerr << "Interna Napaka 1" << endl;
}
return 1+ checkForWin(direction, x, y, counter); // this is recirsive call
}
else
return 0;
}
void Board::display() const
{
system("cls");//clrscr();
cout << "Izvirno kodo je napisal Inder Mohan Singh" << endl;
cout << "Prevedel Bojan Dreu, oktobra 2003" << endl;
cout << "Ce najdes kaksne napake prosim javi na e-mail: imsb69@yahoo.com" << endl;
cout << endl;
cout << endl;
cout << endl;
cout << " " ;
for (int i=1; i <=columnSize; i++)
cout << i << " " ;
cout << endl;
for(int j= rowSize-1; j >=0; j--)
{
cout << " | ";
for(int k=0; k < columnSize; k++)
{
grid[j][k].display();
cout << " | ";
}
cout << endl;
}
for(int m=rowSize; m >=0; m--)
cout << "----";
cout << "--" << endl << endl;
}
Game::Game()
{
Counter :: setTokenNum(); // set static
state = PLAY; // contestants can play
num =0;
board.display(); // display the board
}
void Game:: play()
{
while (state==PLAY)
{
int move = contestant[num].getMove(True);
while(board.moveOkForColumn(move) == False)
move= contestant[num].getMove(False);
board.dropInColumn(move, contestant[num].getCounter());
board.display();
state = board.situation(); // board returns its current state i.e.
// the state of play
if (state == PLAY)
num = (num +1) % NUM_PLAYERS;
else
contestant[num].announce(state);
}
}
|
Back to top
//Hangman Game
//Vislice
//Prevod: Bojan Dreu
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include <fstream.h>
#include <string.h>
inline void type_of_word(char f);
int main()
{ char c,h,ch,ch1,ch2;
char word[25];
char word2[25];
int l,i,ng,n,k,x;
do{
do
{system("cls");//clrscr();
c='\0';
//cout<<"\n\t\t *********** H A N G M A N ***********\n\n\n";
cout<<"\n\t\t ***********************"; //dodal
cout<<"\n\t\t * V I S L I C E *";
cout<<"\n\t\t * Prevedel Bojan Dreu *"; //dodal
cout<<"\n\t\t ***********************\n\n\n"; //dodal
//cout<<"(E) Enter a word\n\n(C) Computer chooses word\n\n(A) Add new word to list\n\n(Q) Quit\n\n\nEnter your choice (E - C - A - Q): ";
cout<<"(E) Vtipkaj besedo\n\n(C) Racunalnik izbere besedo\n\n(A) Dodaj novo besedo na seznam\n\n(Q) Izhod\n\n\nVtipkaj tvojo izbiro (E - C - A - Q): ";
cin>>ch2;
}while (ch2!='C' && ch2!='c' && ch2!='E' && ch2!= 'e' && ch2!='Q' && ch2!= 'q'&& ch2!='A' && ch2!= 'a');
if (ch2 == 'Q' || ch2=='q') exit (0);
if (ch2 == 'C' || ch2=='c')
{
//ifstream fin("hangword.txt");
ifstream fin("vislice_seznam_besed.txt");
if(!fin) { system("cls");//clrscr();
//cout<<"\n\n\n\t\tFile missing, aborting.\n\n\n\nYou are missing a file of name: hangword.txt \n\n\nLocate it, then place it next to the program file.\n\n\n\n\n\n\n\n\n\n"; system("pause"); return 0;}
cout<<"\n\n\n\t\tDatoteka manjka, prekinitev.\n\n\n\nManjka ti datoteka z imenom: vislice_seznam_besed.txt \n\n\nNajdi jo, nato jo namesti zraven programa Hangman.exe.\n\n\n\n\n\n\n\n\n\n"; system("pause"); return 0;}
for (i=0;!fin.eof();i++)
{fin>>c; fin.getline(word,25);}
fin.close();
do {
x=rand();
}while(x>i || x<0);
//ifstream finn("hangword.txt");
ifstream finn("vislice_seznam_besed.txt");
for (i=0;!finn.eof();i++)
{finn>>c; finn.getline(word,25); if (x==i) break;}
finn.close();
}
if (ch2 == 'A' || ch2=='a')
{
system("cls");// clrscr();
//ofstream fout("hangword.txt",ios::app);
ofstream fout("vislice_seznam_besed.txt",ios::app);
if(!fout) {system("cls");//clrscr();
//cout<<"File missing, aborting.\n\nYou are missing a file of name **hangword.txt**\n\nLocate it, then place it next to the program file.\n\n"; system("pause"); return 0;}
cout<<"\n\n\n\t\tDatoteka manjka, prekinitev.\n\n\n\nManjka ti datoteka z imenom: vislice_seznam_besed.txt \n\n\nNajdi jo, nato jo namesti zraven programa Hangman.exe.\n\n\n\n\n\n\n\n\n\n"; system("pause"); return 0;}
cin.get();
//cout<<"Choose the topic of your word\n\n(M) Movie\n\n(A) Animal\n\n(P) Sport\n\n(S) Song\n\nEnter your choice (A-P-S-M) : ";
cout<<"Izberi podrocje za tvojo besedo\n\n(M) Filmi\n\n(A) Zivali\n\n(P) Sport\n\n(S) Pesmi\n\nVtipkaj tvojo izbiro (A-P-S-M) : ";
cin>>h;
cin.get();
system("cls");//clrscr();
//cout<<"\n\nThe word should not exceed 25 letters\n\nEnter the word : ";
cout<<"\n\nBeseda ne sme presegati 25 crk !\n\nVtipkaj besedo : ";
cin.getline(word,25);
fout<<h<<word<<endl;
fout.close();
}
if (ch2 == 'E' || ch2=='e')
{system("cls");// clrscr();
cin.get();
//cout<<"\t\t\t Type the word : ";
cout<<"\t\t\t Vtipkaj besedo : ";
cin.getline (word, 25);
}
if (ch2 == 'E' || ch2=='e' || ch2 == 'C' || ch2=='c')
{
l=strlen(word);
char choosen[25]="\0";
n=0;k=0;
system("cls");//clrscr();
for(i=0;i<=24;i++)
{
if (word[i]=='\0') {word2[i]='\0';break;}
if (word[i]==' ') {word2[i]=' '; n++;}
if (word[i]!=' ') word2[i]='-';
}
ng=l+2-n; //only 2 guesses extra
do{system("cls");//clrscr();
there: type_of_word(c);
//if (k!=0) cout<<"\n\n\t\t\tChoosen letters : "<<choosen<<"\n";
if (k!=0) cout<<"\n\n\t\t\tZe izbrane crke : "<<choosen<<"\n";
//cout<<"\n\n\n\t\t\t "<<word2<<"\n\n\nYou have "<<ng<< " guesses left, choose a letter : ";
cout<<"\n\n\n\t\t\t "<<word2<<"\n\n\nImas "<<ng<< " poskusov na voljo, izberi crko : ";
cin>>ch; cin.get();
for (i=0;i<25;i++) if (choosen[i]==ch) {system("cls");//clrscr();
//cout<<"\a\t\t !!You have choosen "<<ch<<" already!!\n";goto there;}
cout<<"\a\n\n\t\t P O Z O R !! Crko "<<ch<<" si ze izbral !!\n\n\n";goto there;}
ng--; choosen [k]=ch; choosen [k+1]=',';k+=2;
for (i=0;i<=24;i++) if (word[i]==ch || word[i]==ch+32 || word[i]==ch-32) word2[i]=ch;
//if (!strcmpi (word2,word)) {cout<<"\n\n\n\t\t\t "<<strupr(word)<<"\n\n\n\n\n\t\t\tCongratulations :-)\n"; break;}
if (!strcmpi (word2,word)) {cout<<"\n\n\n\t\tIskana beseda je bila : "<<strupr(word)<<"\n\n\n\n\n\t\t\t Cestitam :-)\n"; break;}
}while(ng>0 || !strcmpi (word2,word));
//if (strcmpi (word2,word)) cout<<"\n\n\nSorry, maybe next time.\n\n\n\n\nThe word was : "<<strupr(word)<<endl;
if (strcmpi (word2,word)) cout<<"\n\n\nOprosti, morda bos uspesen kdaj drugic.\n\n\n\n\nIskana beseda je bila : "<<strupr(word)<<endl;
}
//cout<<"\n\n\nWould you like to play again??? (Y - N) : ";
cout<<"\n\n\nBi rad ponovno igral ??? (Y - N) : ";
cin>>ch1; cin.get();
}while (ch1=='y' || ch1=='Y');
//cout<<"\n\n\n"; //odstranil
//system("PAUSE"); //odstranil
return 0;
}
inline void type_of_word(char f)
{
//if (f=='m') cout<<"\n\t\t\t\tMOVIE";
if (f=='m') cout<<"\n\t\t\t\tFILMI";
//if (f=='a') cout<<"\n\t\t\t\tANIMAL";
if (f=='a') cout<<"\n\t\t\t\tZIVALI";
//if (f=='p') cout<<"\n\t\t\t\tSPORT";
if (f=='p') cout<<"\n\t\t\t\tSPORT";
//if (f=='s') cout<<"\n\t\t\t\tSONG";
if (f=='s') cout<<"\n\t\t\t\tPESMI";
}
|
aara
mcvetje v jeseni
mne joci peter
azebra
aslon
akakadu
pboks
pnogomet
pkosarka
scela ulica nori
phelp
mOj kozarcek moj
azajec
aopica
sja ka pa ti tu delas
mdvorana skrivnosti
mgospodar prstanov
mkekec
phokej
prokomet
mmumija
mmatrica
mumri pokoncno
mlevji kralj
mtarzan
akaca
aovca
akoza
stam tam tam
ptenis
amedved
mv vrtincu
psmuk
psmucarski skoki
sna golici
podbojka
pnamizni tenis
psmucanje
pjudo
mgladiator
mking kong
msreca na vrvici
mvrocica sobotne noci
mlepotica in zver
sti si moje sonce
aslon
sne mi dihat za ovratnik
shelp
akrava
|
Back to top
/***************************************************************************
Business Card Program Tutorial
Copyright 2001 Blazon Resources
http://members.home.net/blazonres
Email questions or comments to:
blazonres@home.com
A tutorial on how to print data using an array.
Substituting 'setw()' to replace printing " " from the <iomanip.h>
library can clean up the code a little bit, but this way is easier
for beginners.
Enjoy!
***************************************************************************/
#include <iostream.h>
#include <string.h> //Includes data for 'strlen'
#include <stdio.h>
void centerData(char info[], int &j);
void main()
{
char name[40]; //An array to hold name
char jobTitle[40]; //An array to hold job title
//Get the Name and job title
cout << "Enter your name.\n";
cin.getline(name, 40, '\n'); //Formatted as ('string to save to', 'Maximum length of string', 'When to stop reading the input (here is on a newline)')
cout << "Enter your job title.\n";
cin.getline(jobTitle, 40, '\n');
for (int i = 1; i <= 10; i++) //Create horizontal lines 1 at a time
{
for (int j = 1; j <= 60; j++)
{
if (i == 1) //Top bar
cout << "_";
else if (i == 10) //Bottom bar
cout << "~";
else
{
if ((j == 1) || (j == 60)) //Bar on left and right
cout << "|";
else if ((i == 5) && (j == 2)) //Add name
centerData(name, j);
else if ((i == 6) && (j == 2)) //Add job title
centerData(jobTitle, j);
else //Add a space
cout << " ";
}
}
cout << endl; //End the current line
}
getchar();
}
void centerData(char info[], int &j) //Center the name or job title, note: j is passed by reference and the changes to it are sent back to 'main'
{
int lengthString; //Length of name is stored here
lengthString = strlen(info); //Gets the length of the name
for (j = 2; j < 30 - (lengthString / 2); j++) //Loop enough spaces to center name
//Starts on 2nd space of line goes until halfway - half the length of the string
cout << " "; //Adds one space to space it
j += lengthString - 1; //Adjustment made to j to make the "| |"'s of the line match up
cout << info; //Actually show the name or title on the line
}
|
HOME |
1 | 2 | 3 | 4 | 5 | Next » |
| You are | . visitor of this page. |
Back to topLast updated: 19.03.2008 Copyright © 2006-2012 dr.eu All rights reserved. |