Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include "windows.h"
- #include <conio.h>
- #include <time.h>
- #include <iostream>
- //ustawia kursor we wsp x y
- void gotoxy(int x, int y){
- COORD c;
- c.X = x - 1;
- c.Y = y - 1;
- SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
- }
- void SetColor(int color){
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
- }
- char Character(){
- char tmp = rand()%3;
- if ( tmp == 0 ) {
- return ( rand() % 26 ) + 65; //65-90
- }
- else if( tmp == 1 ){
- return ( rand() % 26 ) + 97; //97-122
- }
- else {
- return ( rand() % 10 ) + 48; //48-57
- }
- }
- void Print(int j, int position){
- SetColor(10);
- if (position<26){
- gotoxy(j, position);
- std::cout<<Character();
- }
- if(position>1 && position<26 ){
- SetColor(2);
- gotoxy(j, position-1);
- std::cout<<Character();
- }
- if(position>15 && position< (26+15) ){
- gotoxy(j, position-15);
- std::cout<<" ";
- }
- }
- void Matrix(){
- int position[80];
- for (int i = 0; i < 80; i ++){
- position[i]=0;
- }
- int j;
- int counter;
- do{
- counter=0;
- j=rand()%80 + 1;
- position[j]++;
- Print(j, position[j]);
- for(int i=0; i < 80; i ++){
- if(position[i]>41){
- counter++;
- }
- }
- if (position[j]>12 && (j>34 && j < 45) ){
- SetColor(10);
- gotoxy(j, 13 );
- switch (j){
- case 35: std::cout<<'D'; break;
- case 36: std::cout<<'a'; break;
- case 37: std::cout<<'w'; break;
- case 38: std::cout<<'i'; break;
- case 39: std::cout<<'d'; break;
- case 40: std::cout<<' '; break;
- case 41: std::cout<<'D'; break;
- case 42: std::cout<<'e'; break;
- case 43: std::cout<<'b'; break;
- case 44: std::cout<<'y'; break;
- }
- }
- if(j%5==0)
- Sleep(1);
- }while (counter<79);
- }
- int main(){
- srand(time(NULL));
- char key;
- SetColor(10);
- gotoxy(31, 13);
- std::cout<<"Mlodszy programista C++";
- Sleep(1000);
- gotoxy(31, 13);
- std::cout<<" ";
- Matrix();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement