├── .vscode ├── c_cpp_properties.json ├── launch.json ├── newwww.html └── tasks.json ├── 10.py ├── 16.py ├── 17875code10200.py ├── 2.py ├── 20.py ├── 7.py ├── CONTRIBUTING.md ├── CarRacingGame ├── bg.jpg ├── blue.png ├── index.html ├── jumpsound.mp3 ├── main.js ├── race.png ├── script.js └── style.css ├── Check_set_bit.cpp ├── README.md ├── SelectionSort.cpp ├── Tic tac toe.py ├── Variable.py ├── basicStructure.cpp ├── butterfly_pattern.cpp ├── c++2022.cpp ├── car_game.c ├── dowhile.cpp ├── even_odd.c ├── favicon_io ├── about.txt ├── android-chrome-192x192.png ├── android-chrome-512x512.png ├── apple-touch-icon.png ├── favicon-16x16.png ├── favicon-32x32.png ├── favicon.ico └── site.webmanifest ├── fibnum.cpp ├── func_OVERLOADING.CPP ├── index.html ├── intersection_of_two_arrays.cpp ├── mallu.cpp ├── month.cpp ├── play_code_c++.cpp ├── pointer_VEDANT.cpp ├── project.html ├── queue.c ├── queue_using_array.c ├── script.js ├── sndkfne.c ├── student_marks.cpp ├── style.css ├── switch.c ├── tut8.html.html ├── weatherbackground.jpg ├── weatherbackground1.jpg └── zigzag.cpp /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Mac", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "defines": [], 9 | "macFrameworkPath": [ 10 | "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks" 11 | ], 12 | "compilerPath": "/usr/bin/clang", 13 | "cStandard": "c17", 14 | "cppStandard": "c++17", 15 | "intelliSenseMode": "macos-clang-arm64" 16 | } 17 | ], 18 | "version": 4 19 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [] 7 | } -------------------------------------------------------------------------------- /.vscode/newwww.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 71 | 72 | 73 | 74 |

Button Colors

75 | 76 |

Change the background color of a button with the background-color property:

77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "type": "cppbuild", 5 | "label": "C/C++: clang++ build active file", 6 | "command": "/usr/bin/clang++", 7 | "args": [ 8 | "-fcolor-diagnostics", 9 | "-fansi-escape-codes", 10 | "-g", 11 | "${file}", 12 | "-o", 13 | "${fileDirname}/${fileBasenameNoExtension}" 14 | ], 15 | "options": { 16 | "cwd": "${fileDirname}" 17 | }, 18 | "problemMatcher": [ 19 | "$gcc" 20 | ], 21 | "group": { 22 | "kind": "build", 23 | "isDefault": true 24 | }, 25 | "detail": "Task generated by Debugger." 26 | } 27 | ], 28 | "version": "2.0.0" 29 | } -------------------------------------------------------------------------------- /10.py: -------------------------------------------------------------------------------- 1 | # Python code to demonstrate string length 2 | # using for loop 3 | 4 | # Returns length of string 5 | def findLen(str): 6 | counter = 0 7 | for i in str: 8 | counter += 1 9 | return counter 10 | 11 | 12 | str = "geeks" 13 | print(findLen(str)) 14 | -------------------------------------------------------------------------------- /16.py: -------------------------------------------------------------------------------- 1 | # Python3 program to swap elements 2 | # at given positions 3 | 4 | # Swap function 5 | def swapPositions(list, pos1, pos2): 6 | 7 | list[pos1], list[pos2] = list[pos2], list[pos1] 8 | return list 9 | 10 | 11 | # Driver function 12 | List = [23, 65, 19, 90] 13 | pos1, pos2 = 1, 3 14 | 15 | print(swapPositions(List, pos1-1, pos2-1)) 16 | -------------------------------------------------------------------------------- /17875code10200.py: -------------------------------------------------------------------------------- 1 | # Function to find permutations of a given string 2 | from itertools import permutations 3 | 4 | 5 | def allPermutations(str): 6 | 7 | # Get all permutations of string 'ABC' 8 | permList = permutations(str) 9 | 10 | # print all permutations 11 | for perm in list(permList): 12 | print(''.join(perm)) 13 | 14 | 15 | # Driver program 16 | if __name__ == "__main__": 17 | str = 'ABC' 18 | allPermutations(str) 19 | -------------------------------------------------------------------------------- /2.py: -------------------------------------------------------------------------------- 1 | # Python program to check 2 | # if a string is binary or not 3 | 4 | # function for checking the 5 | # string is accepted or not 6 | 7 | 8 | def check(string): 9 | 10 | # set function convert string 11 | # into set of characters . 12 | p = set(string) 13 | 14 | # declare set of '0', '1' . 15 | s = {'0', '1'} 16 | 17 | # check set p is same as set s 18 | # or set p contains only '0' 19 | # or set p contains only '1' 20 | # or not, if any one condition 21 | # is true then string is accepted 22 | # otherwise not . 23 | if s == p or p == {'0'} or p == {'1'}: 24 | print("Yes") 25 | else: 26 | print("No") 27 | 28 | 29 | # driver code 30 | if __name__ == "__main__": 31 | 32 | string = "101010000111" 33 | 34 | # function calling 35 | check(string) 36 | -------------------------------------------------------------------------------- /20.py: -------------------------------------------------------------------------------- 1 | # Python program to find sum of elements in list 2 | 3 | total = 0 4 | 5 | # creating a list 6 | list1 = [11, 5, 17, 18, 23] 7 | 8 | # Iterate each element in list 9 | # and add them in variable total 10 | for ele in range(0, len(list1)): 11 | total = total + list1[ele] 12 | 13 | # printing total value 14 | print("Sum of all elements in given list: ", total) 15 | -------------------------------------------------------------------------------- /7.py: -------------------------------------------------------------------------------- 1 | # Python program to demonstrate 2 | # symmetry and palindrome of the 3 | # string 4 | 5 | 6 | # Function to check whether the 7 | # string is palindrome or not 8 | def palindrome(a): 9 | 10 | # finding the mid, start 11 | # and last index of the string 12 | mid = (len(a)-1)//2 # you can remove the -1 or you add <= sign in line 21 13 | start = 0 # so that you can compare the middle elements also. 14 | last = len(a)-1 15 | flag = 0 16 | 17 | # A loop till the mid of the 18 | # string 19 | while(start <= mid): 20 | 21 | # comparing letters from right 22 | # from the letters from left 23 | if (a[start] == a[last]): 24 | 25 | start += 1 26 | last -= 1 27 | 28 | else: 29 | flag = 1 30 | break 31 | 32 | # Checking the flag variable to 33 | # check if the string is palindrome 34 | # or not 35 | if flag == 0: 36 | print("The entered string is palindrome") 37 | else: 38 | print("The entered string is not palindrome") 39 | 40 | # Function to check whether the 41 | # string is symmetrical or not 42 | 43 | 44 | def symmetry(a): 45 | 46 | n = len(a) 47 | flag = 0 48 | 49 | # Check if the string's length 50 | # is odd or even 51 | if n % 2: 52 | mid = n//2 + 1 53 | else: 54 | mid = n//2 55 | 56 | start1 = 0 57 | start2 = mid 58 | 59 | while(start1 < mid and start2 < n): 60 | 61 | if (a[start1] == a[start2]): 62 | start1 = start1 + 1 63 | start2 = start2 + 1 64 | else: 65 | flag = 1 66 | break 67 | 68 | # Checking the flag variable to 69 | # check if the string is symmetrical 70 | # or not 71 | if flag == 0: 72 | print("The entered string is symmetrical") 73 | else: 74 | print("The entered string is not symmetrical") 75 | 76 | 77 | # Driver code 78 | string = 'amaama' 79 | palindrome(string) 80 | symmetry(string) 81 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | this repository is only for algorithms and data structure that use for making car racing app in which you can upload in any language algorithms which will useful for many other people. happy coding 👨‍💻. 2 | -------------------------------------------------------------------------------- /CarRacingGame/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariom20singh/car-racing-game/6c3389f2342535ccf0b87b8055662334eb20b23f/CarRacingGame/bg.jpg -------------------------------------------------------------------------------- /CarRacingGame/blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariom20singh/car-racing-game/6c3389f2342535ccf0b87b8055662334eb20b23f/CarRacingGame/blue.png -------------------------------------------------------------------------------- /CarRacingGame/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Racing moto 8 | 9 | 10 | 11 |
12 |
13 |
14 |
15 |
16 |

Game Over

17 |

18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /CarRacingGame/jumpsound.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariom20singh/car-racing-game/6c3389f2342535ccf0b87b8055662334eb20b23f/CarRacingGame/jumpsound.mp3 -------------------------------------------------------------------------------- /CarRacingGame/main.js: -------------------------------------------------------------------------------- 1 | var blueCar = document.getElementById("bluecar"); 2 | var raceCar = document.getElementById("racecar"); 3 | var result = document.getElementById("result") 4 | const score = document.getElementById("score") 5 | var game = document.getElementById("game"); 6 | var counter = 0; 7 | var jumpsound = document.getElementById("jumpsound") 8 | 9 | 10 | 11 | // bluecar move 12 | blueCar.addEventListener("animationiteration", function(){ 13 | var random = ((Math.floor(Math.random() * 3)) * 130) 14 | blueCar.style.left = random + "px"; 15 | counter++ 16 | }) 17 | 18 | //rececar move 19 | window.addEventListener("keydown", function(e){ 20 | if(e.keyCode == "39"){ var raceCarLeft = parseInt(window.getComputedStyle(raceCar).getPropertyValue("left")) 21 | if(raceCarLeft < 260){raceCar.style.left = (raceCarLeft + 130) + "px"} 22 | jumpsound.play() 23 | }; 24 | 25 | if(e.keyCode == "37"){ 26 | var raceCarLeft = parseInt(window.getComputedStyle(raceCar).getPropertyValue("left")) 27 | if(raceCarLeft > 0){raceCar.style.left = (raceCarLeft - 130) + "px" 28 | jumpsound.play() 29 | } 30 | 31 | } 32 | }) 33 | 34 | 35 | //Game over 36 | setInterval(function Gameover (){ 37 | var blueCarTop = parseInt(window.getComputedStyle(blueCar).getPropertyValue("top")) 38 | var blueCarLeft = parseInt(window.getComputedStyle(blueCar).getPropertyValue("left")); 39 | var raceCarLeft = parseInt(window.getComputedStyle(raceCar).getPropertyValue("left")); 40 | if((blueCarLeft === raceCarLeft) && (blueCarTop > 250) && (blueCarTop < 450)){ 41 | result.style.display = "block"; 42 | game.style.display = "none"; 43 | score.innerHTML = `score: ${counter} `; 44 | 45 | counter = 0; 46 | } 47 | }, 10) 48 | 49 | -------------------------------------------------------------------------------- /CarRacingGame/race.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariom20singh/car-racing-game/6c3389f2342535ccf0b87b8055662334eb20b23f/CarRacingGame/race.png -------------------------------------------------------------------------------- /CarRacingGame/script.js: -------------------------------------------------------------------------------- 1 | window.onload = ()=>{ 2 | var z=document.getElementById("a"); 3 | function song(){ 4 | z.play(); 5 | 6 | } 7 | function endSong(){ 8 | z.pause(); 9 | } 10 | 11 | const score=document.querySelector(".score"); 12 | const startScreen=document.querySelector(".startScreen"); 13 | const gameArea=document.querySelector(".gameArea"); 14 | let btn_a = 15 | document.querySelector('.buttonArea'); 16 | let li = document.querySelectorAll('.buttonArea .ul li'); 17 | 18 | // console.log(gameArea); 19 | 20 | startScreen.addEventListener("click",start); 21 | startScreen.addEventListener("click",song); 22 | 23 | let player={ speed: 6, score:0}; 24 | 25 | 26 | let keys = { ArrowUp:false , ArrowDown:false , ArrowLeft:false,ArrowRight:false} 27 | 28 | 29 | 30 | function isCollide(a,b) 31 | { 32 | aRect = a.getBoundingClientRect(); 33 | bRect = b.getBoundingClientRect(); 34 | 35 | return !((aRect.bottom < bRect.top) || (aRect.top > bRect.bottom ) || (aRect.right < bRect.left) || (aRect.left > bRect.right)) 36 | } 37 | 38 | function moveLines(){ 39 | let lines = document.querySelectorAll(".lines"); 40 | lines.forEach(function(item){ 41 | if(item.y >= 750){ 42 | item.y = -50; 43 | } 44 | item.y += player.speed; 45 | item.style.top= item.y + "px"; 46 | }) 47 | } 48 | 49 | function endGame(){ 50 | player.start=false; 51 | startScreen.classList.remove("hide"); 52 | } 53 | 54 | function moveEnemy(car){ 55 | let enemy = document.querySelectorAll(".enemy"); 56 | enemy.forEach(function(item){ 57 | 58 | if(isCollide(car,item)){ 59 | //console.log("boom hit"); 60 | endGame(); 61 | endSong(); 62 | startScreen.innerHTML="Game over Your score is :-" + player.score+"
" + " click here to restart the game " +" my youtube channel"; 63 | } 64 | 65 | if(item.y >= 700){ 66 | item.y = -300; 67 | item.style.left=Math.floor(Math.random()*250) + "px"; 68 | } 69 | item.y += player.speed; 70 | item.style.top= item.y + "px"; 71 | }) 72 | } 73 | 74 | function gamePlay(){ 75 | //console.log("hey i am clicked"); 76 | let car = document.querySelector(".car"); 77 | let road=gameArea.getBoundingClientRect(); 78 | //console.log(road); 79 | 80 | if(player.start) 81 | { 82 | moveLines(); 83 | moveEnemy(car); 84 | 85 | if(keys.ArrowUp && player.y > road.top+70){ player.y -= player.speed} 86 | if(keys.ArrowDown && player.y < (road.bottom-70)){ player.y += player.speed} 87 | if(keys.ArrowLeft && player.x > 0 ){ player.x -= player.speed} 88 | if(keys.ArrowRight && player.x < (road.width-50)){ player.x += player.speed} 89 | 90 | car.style.top=player.y +"px"; 91 | car.style.left=player.x +"px"; 92 | 93 | window.requestAnimationFrame(gamePlay); 94 | //console.log(player.score++); 95 | score.innerText=" score: " + player.score; 96 | player.score++; 97 | 98 | } 99 | 100 | 101 | } 102 | 103 | function start(){ 104 | 105 | //gameArea.classList.remove('hide'); 106 | startScreen.classList.add('hide'); 107 | 108 | gameArea.innerHTML=""; 109 | 110 | player.start=true; 111 | player.score=0; 112 | 113 | window.requestAnimationFrame(gamePlay); 114 | 115 | for(x=0;x<5;x++) 116 | { 117 | 118 | let roadLine=document.createElement("div"); 119 | roadLine.setAttribute("class","lines"); 120 | roadLine.y=(x*150); 121 | roadLine.style.top=roadLine.y + "px" ; 122 | gameArea.appendChild(roadLine); 123 | } 124 | 125 | let car= document.createElement("div"); 126 | car.setAttribute("class","car"); 127 | //car.innerText= "hay i am your car";/ 128 | gameArea.appendChild(car); 129 | 130 | player.x=car.offsetLeft; 131 | player.y=car.offsetTop; 132 | 133 | 134 | //console.log("top position" +car.offsetTop); 135 | //console.log("left position" +car.offsetLeft) 136 | 137 | for(x=0;x<3;x++) 138 | { 139 | 140 | let enemyCar=document.createElement("div"); 141 | enemyCar.setAttribute("class","enemy"); 142 | enemyCar.y=((x+1)*350) * -1; 143 | enemyCar.style.top=enemyCar.y + "px" ; 144 | enemyCar.style.backgroundColor=randomColor(); 145 | 146 | function randomColor() 147 | { 148 | function c(){ 149 | let hex= Math.floor(Math.random()*256).toString(16); 150 | return ("0" + String(hex)).substr(-2); 151 | } 152 | return "#" + c() +c() +c(); 153 | } 154 | 155 | enemyCar.style.left=Math.floor(Math.random()*250) + "px"; 156 | gameArea.appendChild(enemyCar); 157 | } 158 | 159 | } 160 | 161 | up.addEventListener('touchstart',()=>{ 162 | keys.ArrowUp = true; 163 | }) 164 | up.addEventListener('touchend',()=>{ 165 | keys.ArrowUp = false; 166 | }) 167 | down.addEventListener('touchstart',()=>{ 168 | keys.ArrowDown = true; 169 | }) 170 | down.addEventListener('touchend',()=>{ 171 | keys.ArrowDown = false; 172 | }) 173 | left.addEventListener('touchstart',()=>{ 174 | keys.ArrowLeft = true; 175 | }) 176 | left.addEventListener('touchend',()=>{ 177 | keys.ArrowLeft = false; 178 | }) 179 | right.addEventListener('touchstart',()=>{ 180 | keys.ArrowRight = true; 181 | }) 182 | right.addEventListener('touchend',()=>{ 183 | keys.ArrowRight = false; 184 | }) 185 | 186 | 187 | } -------------------------------------------------------------------------------- /CarRacingGame/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | } 5 | #game{ 6 | height: 500px; 7 | width: 390px; 8 | border: 1px solid black; 9 | margin: 1rem auto; 10 | background:url(bg.jpg) ; 11 | background-size: contain; 12 | overflow: hidden; 13 | } 14 | #bluecar{ 15 | height: 100px; 16 | width: 130px; 17 | background-color: black; 18 | position: relative; 19 | top: 0px; 20 | left: 0px; 21 | text-align: center; 22 | animation: move 1s linear infinite ; 23 | 24 | } 25 | #bluecar img{ 26 | height: 100px; 27 | } 28 | @keyframes move { 29 | 0%{ 30 | top: 0px; 31 | } 32 | 100%{ 33 | top: 501px; 34 | } 35 | 36 | } 37 | #racecar{ 38 | height: 100px; 39 | width: 130px; 40 | background-color: red; 41 | position: relative; 42 | top: 250px; 43 | left: 130px; 44 | text-align: center; 45 | } 46 | #racecar img{ 47 | height: 100px; 48 | } 49 | 50 | #result{ 51 | height: 200px; 52 | width: 400px; 53 | background-color: cornflowerblue; 54 | margin: 1rem auto; 55 | border-radius: 20px; 56 | font-size: 30px; 57 | text-align: center; 58 | color: white; 59 | display:none ; 60 | } 61 | #score{ 62 | font-size: 2.2rem; 63 | color: brown; 64 | } 65 | #btn{ 66 | padding: 0.5rem 1rem; 67 | border-radius: 20px; 68 | border: none; 69 | background-color: black; 70 | color: cyan; 71 | font-size: 25px; 72 | margin-top: 10px; 73 | cursor: pointer; 74 | text-transform: uppercase; 75 | } -------------------------------------------------------------------------------- /Check_set_bit.cpp: -------------------------------------------------------------------------------- 1 | // We have to check that all bits in a given number are set or not 2 | #include 3 | using namespace std; 4 | bool check_set_bit(int n) 5 | { 6 | // If a number is the form of 2^n-1 then it will have all bits set 7 | // we just need to check that pattern 8 | if (n == 0) 9 | return 0; 10 | if (((n) & (n + 1)) == 0) // If n is in the form of 2^n-1 then n+1 will be 2^n 11 | return 1; 12 | return 0; 13 | } 14 | int main() 15 | { 16 | int number; 17 | cin >> number; 18 | cout << check_set_bit(number) << endl; 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # car-racing-game 2 | 3 | car-racing-game for beginner hacktoberfest 4 | # data-structure-# Hacktoberfest-2022🔥 5 | ![image](https://user-images.githubusercontent.com/70385488/192114009-0830321a-d227-4a4d-8411-6c03b54d7ce6.png) 6 | 7 |
8 | 9 | 10 | ### This repository aims to help code beginners with their first successful pull request and open-source contribution. :partying_face: 11 | 12 | :star: Feel free to use this project to make your first contribution to an open-source project on GitHub. Practice making your first pull request to a public repository before doing the real thing! 13 | 14 | :star: Make sure to grab some cool swags during Hacktoberfest by getting involved in the open-source community. 15 | 16 | ### This repository is open to all members of the GitHub community. Any member can contribute to this project! The only thing which you need to keep in mind is that it should be genuine PR :grin: 17 | 18 | ## What is Hacktoberfest? :thinking: 19 | A month-long celebration from October 1st to October 31st presented by [Digital Ocean](https://hacktoberfest.digitalocean.com/) and [DEV Community](https://dev.to/) collaborated with [GitHub](https://github.com/blog/2433-celebrate-open-source-this-october-with-hacktoberfest) to get people involved in [Open Source](https://github.com/open-source). Create your very first pull request to any public repository on GitHub and contribute to the open-source developer community. 20 | 21 | [https://hacktoberfest.digitalocean.com/](https://hacktoberfest.digitalocean.com/) 22 | 23 | ## Rules :fire: 24 | To qualify for the __official limited edition Hacktoberfest shirt__, you must register [here](https://hacktoberfest.digitalocean.com/) and make four Pull Requests (PRs) between October 1-31, 2022 (in any time zone). PRs can be made to any public repo on GitHub, not only the ones with issues labeled Hacktoberfest. This year, the __first 40,000__ participants who complete the challenge will earn a T-shirt. 25 | -------------------------------------------------------------------------------- /SelectionSort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void Selectionsort(int arr[], int n){ 5 | cout<< "Running selection sort "<> n; 33 | 34 | int arr[n]; 35 | for (int i = 0; i < n; i++) 36 | { 37 | cout << "Enter the element of array :- "; 38 | cin >> arr[i]; 39 | } 40 | for (int i = 0; i < n; i++) 41 | { 42 | cout << "your array is :- " << arr[i]< 10: 138 | 139 | raise ValueError("Please guess a number within the given range") 140 | 141 | if int(guess) == random_number: 142 | 143 | print("Nice! You got it!") 144 | 145 | attempts += 1 146 | 147 | attempts_list.append(attempts) 148 | 149 | print("It took you {} attempts".format(attempts)) 150 | 151 | play_again = input("Would you like to play again? (Enter Yes/No) ") 152 | 153 | attempts = 0 154 | 155 | show_score() 156 | 157 | random_number = int(random.randint(1, 10)) 158 | 159 | if play_again.lower() == "no": 160 | 161 | print("That's cool, have a good one!") 162 | 163 | break 164 | 165 | elif int(guess) > random_number: 166 | 167 | print("It's lower") 168 | 169 | attempts += 1 170 | 171 | elif int(guess) < random_number: 172 | 173 | print("It's higher") 174 | 175 | attempts += 1 176 | 177 | except ValueError as err: 178 | 179 | print("Oh no!, that is not a valid value. Try again...") 180 | 181 | print("({})".format(err)) 182 | 183 | else: 184 | 185 | print("That's cool, have a good one!") 186 | 187 | if __name__ == '__main__': 188 | 189 | start_game() 190 | 191 | 192 | 3. Rock Paper Scissors 193 | This rock paper scissors program uses a number of functions so this is a good way of getting that critical concept under your belt. 194 | 195 | 196 | Random function: to generate rock, paper, or scissors. 197 | Valid function: to check the validity of the move. 198 | Result function: to declare the winner of the round. 199 | Scorekeeper: to keep track of the score. 200 | The program requires the user to make the first move before it makes a move. The input could be a string or an alphabet representing either rock, paper or scissors. After evaluating the input string, a winner is decided by the result function and the score of the round is updated by the scorekeeper function. 201 | 202 | Sample Code: 203 | 204 | """ Rock Paper Scissors 205 | 206 | ---------------------------------------- 207 | 208 | """ 209 | 210 | import random 211 | 212 | import os 213 | 214 | import re 215 | 216 | os.system('cls' if os.name=='nt' else 'clear') 217 | 218 | while (1 < 2): 219 | 220 | print ("\n") 221 | 222 | print ("Rock, Paper, Scissors - Shoot!") 223 | 224 | userChoice = input("Choose your weapon [R]ock], [P]aper, or [S]cissors: ") 225 | 226 | if not re.match("[SsRrPp]", userChoice): 227 | 228 | print ("Please choose a letter:") 229 | 230 | print ("[R]ock, [S]cissors or [P]aper.") 231 | 232 | continue 233 | 234 | # Echo the user's choice 235 | 236 | print ("You chose: " + userChoice) 237 | 238 | choices = ['R', 'P', 'S'] 239 | 240 | opponenetChoice = random.choice(choices) 241 | 242 | print ("I chose: " + opponenetChoice) 243 | 244 | if opponenetChoice == str.upper(userChoice): 245 | 246 | print ("Tie! ") 247 | 248 | #if opponenetChoice == str("R") and str.upper(userChoice) == "P" 249 | 250 | elif opponenetChoice == 'R' and userChoice.upper() == 'S': 251 | 252 | print ("Scissors beats rock, I win! ") 253 | 254 | continue 255 | 256 | elif opponenetChoice == 'S' and userChoice.upper() == 'P': 257 | 258 | print ("Scissors beats paper! I win! ") 259 | 260 | continue 261 | 262 | elif opponenetChoice == 'P' and userChoice.upper() == 'R': 263 | 264 | print ("Paper beat rock, I win!") 265 | 266 | continue 267 | 268 | else: 269 | 270 | print ("You win!") 271 | 272 | 273 | 4. Dice Roll Generator 274 | This dice roll generator is a fairly simple program that makes use of the random function to simulate dice rolls. You can change the maximum value to any number, making it possible to simulate polyhedral dice used in many board games and roleplaying games. 275 | 276 | Sample Code: 277 | 278 | import random 279 | 280 | #Enter the minimum and maximum limits of the dice rolls below 281 | 282 | min_val = 1 283 | 284 | max_val = 6 285 | 286 | #the variable that stores the user’s decision 287 | 288 | roll_again = "yes" 289 | 290 | #The dice roll loop if the user wants to continue 291 | 292 | while roll_again == "yes" or roll_again == "y": 293 | 294 | print("Dices rolling...") 295 | 296 | print("The values are :") 297 | 298 | #Printing the randomly generated variable of the first dice 299 | 300 | print(random.randint(min_val, max_val)) 301 | 302 | #Printing the randomly generated variable of the second dice 303 | 304 | print(random.randint(min_val, max_val)) 305 | 306 | #Here the user enters yes or y to continue and any other input ends the program 307 | 308 | roll_again = input("Roll the Dices Again?") 309 | 310 | 311 | 5. Binary Search Algorithm 312 | The binary search algorithm is a very important one, and requires you to create a list of numbers between 0 and an upper limit, with every succeeding number having a difference of 2 between them. 313 | 314 | When the user inputs a random number to be searched the program begins its search by dividing the list into two halves. First, the first half is searched for the required number and if found, the other half is rejected and vice versa. The search continues until the number is found or the subarray size becomes zero. 315 | 316 | Sample Code: 317 | 318 | # Recursive Binary Search algorithm in Python 319 | 320 | def binarySearch(array, x, low, high): 321 | 322 | if high >= low: 323 | 324 | mid = low + (high - low)//2 325 | 326 | # If found at mid, return the value 327 | 328 | if array[mid] == x: 329 | 330 | return mid 331 | 332 | # Search the first half 333 | 334 | elif array[mid] > x: 335 | 336 | return binarySearch(array, x, low, mid-1) 337 | 338 | # Search the second half 339 | 340 | else: 341 | 342 | return binarySearch(array, x, mid + 1, high) 343 | 344 | else: 345 | 346 | return -1 347 | 348 | array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 349 | 350 | x = int(input("Enter a number between 1 and 10:")) 351 | 352 | result = binarySearch(array, x, 0, len(array)-1) 353 | 354 | if result != -1: 355 | 356 | print("Element is present at position" + str(result)) 357 | 358 | else: 359 | 360 | print("Element not found") 361 | 362 | 363 | 364 | 365 | 6. Calculator 366 | This project teaches you to design a graphical interface and is a good way to get familiar with a library like Tkinter. This library lets you create buttons to perform different operations and display results on the screen. 367 | 368 | Sample Code: 369 | 370 | # Calculator 371 | 372 | def addition (): 373 | 374 | print("Addition") 375 | 376 | n = float(input("Enter the number: ")) 377 | 378 | t = 0 #Total number enter 379 | 380 | ans = 0 381 | 382 | while n != 0: 383 | 384 | ans = ans + n 385 | 386 | t+=1 387 | 388 | n = float(input("Enter another number (0 to calculate): ")) 389 | 390 | return [ans,t] 391 | 392 | def subtraction (): 393 | 394 | print("Subtraction"); 395 | 396 | n = float(input("Enter the number: ")) 397 | 398 | t = 0 #Total number enter 399 | 400 | sum = 0 401 | 402 | while n != 0: 403 | 404 | ans = ans - n 405 | 406 | t+=1 407 | 408 | n = float(input("Enter another number (0 to calculate): ")) 409 | 410 | return [ans,t] 411 | 412 | def multiplication (): 413 | 414 | print("Multiplication") 415 | 416 | n = float(input("Enter the number: ")) 417 | 418 | t = 0 #Total number enter 419 | 420 | ans = 1 421 | 422 | while n != 0: 423 | 424 | ans = ans * n 425 | 426 | t+=1 427 | 428 | n = float(input("Enter another number (0 to calculate): ")) 429 | 430 | return [ans,t] 431 | 432 | def average(): 433 | 434 | an = [] 435 | 436 | an = addition() 437 | 438 | t = an[1] 439 | 440 | a = an[0] 441 | 442 | ans = a / t 443 | 444 | return [ans,t] 445 | 446 | # main... 447 | 448 | while True: 449 | 450 | list = [] 451 | 452 | print(" My first python program!") 453 | 454 | print(" Simple Calculator in python by Malik Umer Farooq") 455 | 456 | print(" Enter 'a' for addition") 457 | 458 | print(" Enter 's' for substraction") 459 | 460 | print(" Enter 'm' for multiplication") 461 | 462 | print(" Enter 'v' for average") 463 | 464 | print(" Enter 'q' for quit") 465 | 466 | c = input(" ") 467 | 468 | if c != 'q': 469 | 470 | if c == 'a': 471 | 472 | list = addition() 473 | 474 | print("Ans = ", list[0], " total inputs ",list[1]) 475 | 476 | elif c == 's': 477 | 478 | list = subtraction() 479 | 480 | print("Ans = ", list[0], " total inputs ",list[1]) 481 | 482 | elif c == 'm': 483 | 484 | list = multiplication() 485 | 486 | print("Ans = ", list[0], " total inputs ",list[1]) 487 | 488 | elif c == 'v': 489 | 490 | list = average() 491 | 492 | print("Ans = ", list[0], " total inputs ",list[1]) 493 | 494 | else: 495 | 496 | print ("Sorry, invilid character") 497 | 498 | else: 499 | 500 | break 501 | 502 | 503 | 7. Alarm Clock 504 | This Command Line Interface (CLI) Python application is a good step up for a beginner developer. More than just setting off an alarm, this program allows certain YouTube links to be added to a text file. When a user sets an alarm, the code picks a random video and starts playing it. 505 | 506 | 507 | Sample Code: 508 | 509 | """ Alarm Clock 510 | 511 | ---------------------------------------- 512 | 513 | """ 514 | 515 | import datetime 516 | 517 | import os 518 | 519 | import time 520 | 521 | import random 522 | 523 | import webbrowser 524 | 525 | # If video URL file does not exist, create one 526 | 527 | if not os.path.isfile("youtube_alarm_videos.txt"): 528 | 529 | print('Creating "youtube_alarm_videos.txt"...') 530 | 531 | with open("youtube_alarm_videos.txt", "w") as alarm_file: 532 | 533 | alarm_file.write("https://www.youtube.com/watch?v=anM6uIZvx74") 534 | 535 | def check_alarm_input(alarm_time): 536 | 537 | """Checks to see if the user has entered in a valid alarm time""" 538 | 539 | if len(alarm_time) == 1: # [Hour] Format 540 | 541 | if alarm_time[0] < 24 and alarm_time[0] >= 0: 542 | 543 | return True 544 | 545 | if len(alarm_time) == 2: # [Hour:Minute] Format 546 | 547 | if alarm_time[0] < 24 and alarm_time[0] >= 0 and \ 548 | 549 | alarm_time[1] < 60 and alarm_time[1] >= 0: 550 | 551 | return True 552 | 553 | elif len(alarm_time) == 3: # [Hour:Minute:Second] Format 554 | 555 | if alarm_time[0] < 24 and alarm_time[0] >= 0 and \ 556 | 557 | alarm_time[1] < 60 and alarm_time[1] >= 0 and \ 558 | 559 | alarm_time[2] < 60 and alarm_time[2] >= 0: 560 | 561 | return True 562 | 563 | return False 564 | 565 | # Get user input for the alarm time 566 | 567 | print("Set a time for the alarm (Ex. 06:30 or 18:30:00)") 568 | 569 | while True: 570 | 571 | alarm_input = input(">> ") 572 | 573 | try: 574 | 575 | alarm_time = [int(n) for n in alarm_input.split(":")] 576 | 577 | if check_alarm_input(alarm_time): 578 | 579 | break 580 | 581 | else: 582 | 583 | raise ValueError 584 | 585 | except ValueError: 586 | 587 | print("ERROR: Enter time in HH:MM or HH:MM:SS format") 588 | 589 | # Convert the alarm time from [H:M] or [H:M:S] to seconds 590 | 591 | seconds_hms = [3600, 60, 1] # Number of seconds in an Hour, Minute, and Second 592 | 593 | alarm_seconds = sum([a*b for a,b in zip(seconds_hms[:len(alarm_time)], alarm_time)]) 594 | 595 | # Get the current time of day in seconds 596 | 597 | now = datetime.datetime.now() 598 | 599 | current_time_seconds = sum([a*b for a,b in zip(seconds_hms, [now.hour, now.minute, now.second])]) 600 | 601 | # Calculate the number of seconds until alarm goes off 602 | 603 | time_diff_seconds = alarm_seconds - current_time_seconds 604 | 605 | # If time difference is negative, set alarm for next day 606 | 607 | if time_diff_seconds < 0: 608 | 609 | time_diff_seconds += 86400 # number of seconds in a day 610 | 611 | # Display the amount of time until the alarm goes off 612 | 613 | print("Alarm set to go off in %s" % datetime.timedelta(seconds=time_diff_seconds)) 614 | 615 | # Sleep until the alarm goes off 616 | 617 | time.sleep(time_diff_seconds) 618 | 619 | # Time for the alarm to go off 620 | 621 | print("Wake Up!") 622 | 623 | # Load list of possible video URLs 624 | 625 | with open("youtube_alarm_videos.txt", "r") as alarm_file: 626 | 627 | videos = alarm_file.readlines() 628 | 629 | # Open a random video from the list 630 | 631 | webbrowser.open(random.choice(videos)) 632 | 633 | 634 | 8. Tic-Tac-Toe 635 | Tic-Tac-Toe is a two-player game that involves a nine-square grid. Each player marks their space with an O or an X alternately. The player who manages to mark three Os or Xs diagonally, horizontally, or vertically wins. Each player must block their opponent while attempting to make their chain. For this project, we use the Pygame Python library. 636 | 637 | 638 | Sample Code: 639 | 640 | """ Tic Tac Toe 641 | 642 | ---------------------------------------- 643 | 644 | """ 645 | 646 | import random 647 | 648 | import sys 649 | 650 | board=[i for i in range(0,9)] 651 | 652 | player, computer = '','' 653 | 654 | # Corners, Center and Others, respectively 655 | 656 | moves=((1,7,3,9),(5,),(2,4,6,8)) 657 | 658 | # Winner combinations 659 | 660 | winners=((0,1,2),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6)) 661 | 662 | # Table 663 | 664 | tab=range(1,10) 665 | 666 | def print_board(): 667 | 668 | x=1 669 | 670 | for i in board: 671 | 672 | end = ' | ' 673 | 674 | if x%3 == 0: 675 | 676 | end = ' \n' 677 | 678 | if i != 1: end+='---------\n'; 679 | 680 | char=' ' 681 | 682 | if i in ('X','O'): char=i; 683 | 684 | x+=1 685 | 686 | print(char,end=end) 687 | 688 | def select_char(): 689 | 690 | chars=('X','O') 691 | 692 | if random.randint(0,1) == 0: 693 | 694 | return chars[::-1] 695 | 696 | return chars 697 | 698 | def can_move(brd, player, move): 699 | 700 | if move in tab and brd[move-1] == move-1: 701 | 702 | return True 703 | 704 | return False 705 | 706 | def can_win(brd, player, move): 707 | 708 | places=[] 709 | 710 | x=0 711 | 712 | for i in brd: 713 | 714 | if i == player: places.append(x); 715 | 716 | x+=1 717 | 718 | win=True 719 | 720 | for tup in winners: 721 | 722 | win=True 723 | 724 | for ix in tup: 725 | 726 | if brd[ix] != player: 727 | 728 | win=False 729 | 730 | break 731 | 732 | if win == True: 733 | 734 | break 735 | 736 | return win 737 | 738 | def make_move(brd, player, move, undo=False): 739 | 740 | if can_move(brd, player, move): 741 | 742 | brd[move-1] = player 743 | 744 | win=can_win(brd, player, move) 745 | 746 | if undo: 747 | 748 | brd[move-1] = move-1 749 | 750 | return (True, win) 751 | 752 | return (False, False) 753 | 754 | # AI goes here 755 | 756 | def computer_move(): 757 | 758 | move=-1 759 | 760 | # If I can win, others do not matter. 761 | 762 | for i in range(1,10): 763 | 764 | if make_move(board, computer, i, True)[1]: 765 | 766 | move=i 767 | 768 | break 769 | 770 | if move == -1: 771 | 772 | # If player can win, block him. 773 | 774 | for i in range(1,10): 775 | 776 | if make_move(board, player, i, True)[1]: 777 | 778 | move=i 779 | 780 | break 781 | 782 | if move == -1: 783 | 784 | # Otherwise, try to take one of desired places. 785 | 786 | for tup in moves: 787 | 788 | for mv in tup: 789 | 790 | if move == -1 and can_move(board, computer, mv): 791 | 792 | move=mv 793 | 794 | break 795 | 796 | return make_move(board, computer, move) 797 | 798 | def space_exist(): 799 | 800 | return board.count('X') + board.count('O') != 9 801 | 802 | player, computer = select_char() 803 | 804 | print('Player is [%s] and computer is [%s]' % (player, computer)) 805 | 806 | result='%%% Deuce ! %%%' 807 | 808 | while space_exist(): 809 | 810 | print_board() 811 | 812 | print('#Make your move ! [1-9] : ', end='') 813 | 814 | move = int(input()) 815 | 816 | moved, won = make_move(board, player, move) 817 | 818 | if not moved: 819 | 820 | print(' >> Invalid number ! Try again !') 821 | 822 | continue 823 | 824 | if won: 825 | 826 | result='*** Congratulations ! You won ! ***' 827 | 828 | break 829 | 830 | elif computer_move()[1]: 831 | 832 | result='=== You lose ! ==' 833 | 834 | break; 835 | 836 | print_board() 837 | 838 | print(result) 839 | -------------------------------------------------------------------------------- /Variable.py: -------------------------------------------------------------------------------- 1 | 2 | var1 = "Hello World\n" 3 | var4= " people" 4 | var2 = 4 5 | var3 = 36.7 6 | # print(10 * var1) This will print hello world 10 times 7 | # print(type(var1)) 8 | # print(type(var2)) 9 | # print(type(var3)) 10 | # print(100 * (var2 + var3)) mulitply two given number 11 | 12 | # print(var1) 13 | # print(var2) 14 | # print(var3) 15 | # print(var1 + var4) 16 | # print(var1 + var3) 17 | 18 | v1 = "56\n" 19 | v2 = "56\n" 20 | # print(v1 + v2) print 5656 because it concatente both 56 because 56 is defined under string 21 | # print(int(v1) + int(v2)) Now it will print 112 because string is typecasted to integer 22 | 23 | # print( 10*(v1 + v2)) This will show 5656565656565656565656565656565656565656 24 | # becuse this is string 25 | 26 | 27 | # print(10* (int(v1) + int(v2))) this will show correct multiply that is 1120 because here string is typecasted into string and then multiplied by 10 28 | 29 | # quick quiz on type casting(sum of two Number) 30 | 31 | # print("Enter Any integer") 32 | # v1 = input() 33 | # print("Enter Any integer") 34 | # v2 = input() 35 | # print("The sum of given integer is ") 36 | # print(int(v1) + int(v2)) 37 | -------------------------------------------------------------------------------- /basicStructure.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | struct teachers{ 4 | string name; 5 | int age; 6 | int salary; 7 | bool english; 8 | string gender; 9 | void print() 10 | { 11 | cout<<"Name : "<>n; 23 | teachers teacher[n]; 24 | // teacher[0].name="Aniket"; 25 | // teacher[0].age=21; 26 | // teacher[0].salary=0; 27 | // teacher[0].english=true; 28 | // teacher[0].gender="Male"; 29 | 30 | // teacher[1].name="Lokesh"; 31 | // teacher[1].age=22; 32 | // teacher[1].salary=5000000; 33 | // teacher[1].english=true; 34 | // teacher[1].gender="Male"; 35 | 36 | // teacher[2].name="Diwakar"; 37 | // teacher[2].age=23; 38 | // teacher[2].salary=100000000; 39 | // teacher[2].english=true; 40 | // teacher[2].gender="Male"; 41 | 42 | // teacher[3].name="Ritik"; 43 | // teacher[3].age=20; 44 | // teacher[3].salary=250000; 45 | // teacher[3].english=true; 46 | // teacher[3].gender="Male"; 47 | 48 | // teacher[4].name="Aloki"; 49 | // teacher[4].age=19; 50 | // teacher[4].salary=10; 51 | // teacher[4].english=false; 52 | // teacher[4].gender="Female"; 53 | 54 | for(int i=0;i>teacher[i].name; 57 | cout<<"Teacher's "<>teacher[i].age; 59 | cout<<"Teacher's "<>teacher[i].salary; 61 | cout<<"Teacher's "<>teacher[i].english; 63 | cout<<"Teacher's "<>teacher[i].gender; 65 | cout< 2 | using namespace std; 3 | int main(){ 4 | int n; 5 | cin>>n; 6 | 7 | for(int i=1;i<=n;i++){ 8 | for(int j=1;j<=i;j++){ 9 | cout<<"*"; 10 | } 11 | int space = 2*n- 2*i; 12 | for(int j=1;j<=space;j++){ 13 | cout<<" "; 14 | } 15 | for(int j=1;j<=i;j++){ 16 | cout<<"*"; 17 | } 18 | cout<=1;i--){ 22 | for(int j=1;j<=i;j++){ 23 | cout<<"*"; 24 | } 25 | int space = 2*n- 2*i; 26 | for(int j=1;j<=space;j++){ 27 | cout<<" "; 28 | } 29 | for(int j=1;j<=i;j++){ 30 | cout<<"*"; 31 | } 32 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | cout<<"hello moto"; 7 | return 0; 8 | } -------------------------------------------------------------------------------- /car_game.c: -------------------------------------------------------------------------------- 1 | /* 2 | Language: C\C++ (To convert to C, just change cout 3 | to printf and cin to scanf and change the library files) 4 | Category: Games\Graphics 5 | Description: RACE CRAZE::A car racing game. 6 | 7 | You have to reach the finish line before the time goes out. 8 | There are many hurdles in your way. 9 | So be careful. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | class car 22 | { 23 | private: 24 | int x1,y1,x2,y2,col,col2,col3; 25 | public: 26 | car():x1(200),y1(300),x2(270),y2(200),col(4) 27 | {} 28 | car(int a,int b,int c,int d,int e,int f,int 29 | g):x1(a),y1(b),x2(c),y2(d),col(e),col2(f),col3(g) 30 | {} 31 | void get(int a,int b,int c,int d,int e,int f,int g) 32 | { 33 | x1=a; 34 | y1=b; 35 | x2=c; 36 | y2=d; 37 | col=e; 38 | col2=f; 39 | col3=g; 40 | if (x1<=180) 41 | { 42 | sound(1000); 43 | x1=200; 44 | x2=270; 45 | } 46 | if (x2>=430) 47 | { 48 | sound(1000); 49 | x1=340; 50 | x2=410; 51 | } 52 | } 53 | void draw() 54 | { 55 | setcolor(col); 56 | setfillstyle(1,col); 57 | rectangle(x1,y1,x2,y2); //car body 58 | floodfill(x1+10,y2+10,col); 59 | setcolor(col2); //windows 60 | setfillstyle(2,col2); 61 | rectangle(x1+10,y1-70,x2-10,y2+10); 62 | floodfill(x1+15,y2+15,col2); 63 | rectangle(x1+10,y1-10,x2-10,y2+70); 64 | floodfill(x1+15,y1-15,col2); 65 | setcolor(col3); //wheels 66 | setfillstyle(1,col3); 67 | rectangle(x1-10,y2+5,x1,y2+20); 68 | floodfill(x1-4,y2+12,col3); 69 | rectangle(x2,y2+5,x2+10,y2+20); 70 | floodfill(x2+4,y2+12,col3); 71 | rectangle(x1-15+1,y1-25,x1,y1-5); 72 | floodfill(x1-10,y1-20,col3); 73 | rectangle(x2,y1-25,x2+15,y1-5); 74 | floodfill(x2+4,y1-20,col3); 75 | } 76 | void collide(int col) 77 | { 78 | setcolor(col); 79 | setfillstyle(1,col); 80 | line(x1-5,y2-3,x1,y2); 81 | line(x1-5,y2-5,x1,y2-5); 82 | line(x1-5,y2-3,x1-5,y2-5); 83 | line(x1,y2-5,x1+5,y2-3); 84 | line(x1+5,y2-3,x1+10,y2-15); 85 | line(x1+10,y2-15,x1+20,y2-3); 86 | line(x1+20,y2-3,x1+30,y2-10); 87 | line(x1+30,y2-10,x1+35,y2-3); 88 | line(x1+35,y2-3,x1+45,y2-12); 89 | line(x1+45,y2-12,x1+55,y2-3); 90 | line(x1+55,y2-3,x1+60,y2-10); 91 | line(x1+60,y2-10,x1+70,y2-3); 92 | line(x1+70,y2-3,x1+74,y2-8); 93 | line(x1+74,y2-8,x1+70,y2); 94 | line(x1,y2,x1+70,y2); 95 | floodfill(x1+30,y2-1,col); 96 | line(x1-5,y1+3,x1,y1); 97 | line(x1-5,y1+5,x1,y1+5); 98 | line(x1-5,y1+3,x1-5,y1+5); 99 | line(x1,y1+5,x1+5,y1+3); 100 | line(x1+5,y1+3,x1+10,y1+15); 101 | line(x1+10,y1+15,x1+20,y1+3); 102 | line(x1+20,y1+3,x1+30,y1+10); 103 | line(x1+30,y1+10,x1+35,y1+3); 104 | line(x1+35,y1+3,x1+45,y1+12); 105 | line(x1+45,y1+12,x1+55,y1+3); 106 | line(x1+55,y1+3,x1+60,y1+10); 107 | line(x1+60,y1+10,x1+70,y1+3); 108 | line(x1+70,y1+3,x1+74,y1+8); 109 | line(x1+74,y1+8,x1+70,y1); 110 | line(x1,y1,x1+70,y1); 111 | floodfill(x1+30,y1+1,col); 112 | } 113 | }; 114 | 115 | 116 | class obstacle 117 | { 118 | private: 119 | int x,y,col; 120 | public: 121 | obstacle():x(0),y(0),col(0) 122 | {} 123 | obstacle(int a,int b,int c):x(a),y(b),col(c) 124 | {} 125 | void get(int a,int b,int c) 126 | { 127 | x=a; 128 | y=b; 129 | col=c; 130 | } 131 | void draw() 132 | { 133 | setcolor(col); 134 | setfillstyle(1,col); 135 | circle(x,y,20); 136 | floodfill(x,y,col); 137 | } 138 | }; 139 | 140 | 141 | class timer 142 | { 143 | private: 144 | int sec,min,ms,flag; 145 | public: 146 | timer():min(0),sec(0),ms(0),flag(0) 147 | {} 148 | timer(int a,int b,int c,int d):min(a),sec(b),ms(c),flag(d) 149 | {} 150 | void start() 151 | { 152 | min=sec=ms=flag=0; 153 | } 154 | void get() 155 | { 156 | settextstyle(1,0,1); 157 | char* minn; 158 | if (min>9) 159 | { 160 | int minnn=min/10; 161 | if (minnn==0) 162 | minn="0"; 163 | if (minnn==1) 164 | minn="1"; 165 | if (minnn==2) 166 | minn="2"; 167 | if (minnn==3) 168 | minn="3"; 169 | if (minnn==4) 170 | minn="4"; 171 | if (minnn==5) 172 | minn="5"; 173 | if (minnn==6) 174 | minn="6"; 175 | if (minnn==7) 176 | minn="7"; 177 | if (minnn==8) 178 | minn="8"; 179 | if (minnn==9) 180 | minn="9"; 181 | setcolor(15); 182 | outtextxy(20,100,minn); 183 | setcolor(0); 184 | outtextxy(20,100,minn); 185 | } 186 | if (min>9) 187 | { 188 | int minnn=min%10; 189 | if (minnn==0) 190 | minn="0"; 191 | if (minnn==1) 192 | minn="1"; 193 | if (minnn==2) 194 | minn="2"; 195 | if (minnn==3) 196 | minn="3"; 197 | if (minnn==4) 198 | minn="4"; 199 | if (minnn==5) 200 | minn="5"; 201 | if (minnn==6) 202 | minn="6"; 203 | if (minnn==7) 204 | minn="7"; 205 | if (minnn==8) 206 | minn="8"; 207 | if (minnn==9) 208 | minn="9"; 209 | setcolor(15); 210 | outtextxy(30,100,minn); 211 | setcolor(0); 212 | outtextxy(30,100,minn); 213 | } 214 | if (min<=9) 215 | { 216 | int minnn=min; 217 | if (minnn==0) 218 | minn="0"; 219 | if (minnn==1) 220 | minn="1"; 221 | if (minnn==2) 222 | minn="2"; 223 | if (minnn==3) 224 | minn="3"; 225 | if (minnn==4) 226 | minn="4"; 227 | if (minnn==5) 228 | minn="5"; 229 | if (minnn==6) 230 | minn="6"; 231 | if (minnn==7) 232 | minn="7"; 233 | if (minnn==8) 234 | minn="8"; 235 | if (minnn==9) 236 | minn="9"; 237 | setcolor(15); 238 | outtextxy(20,100,minn); 239 | setcolor(0); 240 | outtextxy(20,100,minn); 241 | } 242 | setcolor(15); 243 | outtextxy(40,100,":"); 244 | if (sec>9) 245 | { 246 | int minnn=sec/10; 247 | if (minnn==0) 248 | minn="0"; 249 | if (minnn==1) 250 | minn="1"; 251 | if (minnn==2) 252 | minn="2"; 253 | if (minnn==3) 254 | minn="3"; 255 | if (minnn==4) 256 | minn="4"; 257 | if (minnn==5) 258 | minn="5"; 259 | if (minnn==6) 260 | minn="6"; 261 | if (minnn==7) 262 | minn="7"; 263 | if (minnn==8) 264 | minn="8"; 265 | if (minnn==9) 266 | minn="9"; 267 | setcolor(15); 268 | outtextxy(50,100,minn); 269 | setcolor(0); 270 | outtextxy(50,100,minn); 271 | } 272 | if (sec>9) 273 | { 274 | int minnn=sec%10; 275 | if (minnn==0) 276 | minn="0"; 277 | if (minnn==1) 278 | minn="1"; 279 | if (minnn==2) 280 | minn="2"; 281 | if (minnn==3) 282 | minn="3"; 283 | if (minnn==4) 284 | minn="4"; 285 | if (minnn==5) 286 | minn="5"; 287 | if (minnn==6) 288 | minn="6"; 289 | if (minnn==7) 290 | minn="7"; 291 | if (minnn==8) 292 | minn="8"; 293 | if (minnn==9) 294 | minn="9"; 295 | setcolor(15); 296 | outtextxy(60,100,minn); 297 | setcolor(0); 298 | outtextxy(60,100,minn); 299 | } 300 | if (sec<=9) 301 | { 302 | int minnn=sec; 303 | if (minnn==0) 304 | minn="0"; 305 | if (minnn==1) 306 | minn="1"; 307 | if (minnn==2) 308 | minn="2"; 309 | if (minnn==3) 310 | minn="3"; 311 | if (minnn==4) 312 | minn="4"; 313 | if (minnn==5) 314 | minn="5"; 315 | if (minnn==6) 316 | minn="6"; 317 | if (minnn==7) 318 | minn="7"; 319 | if (minnn==8) 320 | minn="8"; 321 | if (minnn==9) 322 | minn="9"; 323 | setcolor(15); 324 | outtextxy(50,100,minn); 325 | setcolor(0); 326 | outtextxy(50,100,minn); 327 | } 328 | setcolor(15); 329 | outtextxy(70,100,":"); 330 | if (ms>9) 331 | { 332 | int minnn=ms/10; 333 | if (minnn==0) 334 | minn="0"; 335 | if (minnn==1) 336 | minn="1"; 337 | if (minnn==2) 338 | minn="2"; 339 | if (minnn==3) 340 | minn="3"; 341 | if (minnn==4) 342 | minn="4"; 343 | if (minnn==5) 344 | minn="5"; 345 | if (minnn==6) 346 | minn="6"; 347 | if (minnn==7) 348 | minn="7"; 349 | if (minnn==8) 350 | minn="8"; 351 | if (minnn==9) 352 | minn="9"; 353 | setcolor(15); 354 | outtextxy(80,100,minn); 355 | setcolor(0); 356 | outtextxy(80,100,minn); 357 | } 358 | if (ms>9) 359 | { 360 | int minnn=ms%10; 361 | if (minnn==0) 362 | minn="0"; 363 | if (minnn==1) 364 | minn="1"; 365 | if (minnn==2) 366 | minn="2"; 367 | if (minnn==3) 368 | minn="3"; 369 | if (minnn==4) 370 | minn="4"; 371 | if (minnn==5) 372 | minn="5"; 373 | if (minnn==6) 374 | minn="6"; 375 | if (minnn==7) 376 | minn="7"; 377 | if (minnn==8) 378 | minn="8"; 379 | if (minnn==9) 380 | minn="9"; 381 | setcolor(15); 382 | outtextxy(90,100,minn); 383 | setcolor(0); 384 | outtextxy(90,100,minn); 385 | } 386 | if (ms<=9) 387 | { 388 | int minnn=ms; 389 | if (minnn==0) 390 | minn="0"; 391 | if (minnn==1) 392 | minn="1"; 393 | if (minnn==2) 394 | minn="2"; 395 | if (minnn==3) 396 | minn="3"; 397 | if (minnn==4) 398 | minn="4"; 399 | if (minnn==5) 400 | minn="5"; 401 | if (minnn==6) 402 | minn="6"; 403 | if (minnn==7) 404 | minn="7"; 405 | if (minnn==8) 406 | minn="8"; 407 | if (minnn==9) 408 | minn="9"; 409 | setcolor(15); 410 | outtextxy(80,100,minn); 411 | setcolor(0); 412 | outtextxy(80,100,minn); 413 | } 414 | } 415 | void time() 416 | { 417 | ms++; 418 | if (ms==100) 419 | { 420 | ms=0; 421 | sec++; 422 | } 423 | if (sec==60) 424 | { 425 | sec=0; 426 | min++; 427 | } 428 | } 429 | int minutes() 430 | { 431 | return min; 432 | } 433 | void timego() 434 | { 435 | ms=0; 436 | sec+=30; 437 | if (sec>60) 438 | { 439 | sec=0; 440 | min++; 441 | } 442 | } 443 | }; 444 | void grass() 445 | { 446 | setcolor(10); 447 | setfillstyle(1,10); 448 | rectangle(0,0,180,400); 449 | floodfill(10,100,10); 450 | rectangle(430,0,600,400); 451 | floodfill(480,100,10); 452 | setcolor(5); 453 | settextstyle(8,0,3); 454 | outtextxy(440,50,"RACE CRAZE"); 455 | setcolor(0); 456 | setfillstyle(1,0); 457 | settextstyle(7,0,2); 458 | outtextxy(20,60,"TIMER"); 459 | rectangle(20,100,150,130); 460 | floodfill(60,120,0); 461 | settextstyle(7,0,2); 462 | outtextxy(20,260,"MILES"); 463 | rectangle(20,300,150,330); 464 | floodfill(60,320,0); 465 | } 466 | void track(int n,int coll) 467 | { 468 | setcolor(coll); 469 | setfillstyle(1,coll); 470 | rectangle(300,n,310,50+n); 471 | floodfill(302,10+n,coll); 472 | rectangle(300,100+n,310,150+n); 473 | floodfill(302,110+n,coll); 474 | rectangle(300,200+n,310,250+n); 475 | floodfill(302,210+n,coll); 476 | rectangle(300,300+n,310,350+n); 477 | floodfill(302,310+n,coll); 478 | rectangle(300,400+n,310,450+n); 479 | floodfill(302,410+n,coll); 480 | rectangle(300,500+n,310,550+n); 481 | floodfill(302,510+n,coll); 482 | rectangle(300,600+n,310,650+n); 483 | floodfill(302,610+n,coll); 484 | rectangle(300,700+n,310,750+n); 485 | floodfill(302,710+n,coll); 486 | } 487 | void main() 488 | { 489 | int driver,mode; 490 | driver=EGA; 491 | mode=EGAHI; 492 | initgraph(&driver,&mode,"c:\\tc\\bgi"); 493 | car c,c1; 494 | obstacle o; 495 | timer T; 496 | int i,j=200,k=200; 497 | int t=-200,flg=0; 498 | time_t tt,ttt; 499 | c.get(k,j+100,k+70,j,4,3,8); 500 | c.draw(); 501 | grass(); 502 | track(t,15); 503 | randomize(); 504 | int r=0,r1,l=50; 505 | int miles=0,mil=0; 506 | int stage=10; 507 | getch(); 508 | do 509 | { 510 | T.get(); 511 | i=0; 512 | if (kbhit()) 513 | i=getch(); 514 | T.time(); 515 | char* minn; 516 | settextstyle(1,0,1); 517 | if (miles>99) 518 | { 519 | int minnn=miles/100; 520 | if (minnn==0) 521 | minn="0"; 522 | if (minnn==1) 523 | minn="1"; 524 | if (minnn==2) 525 | minn="2"; 526 | if (minnn==3) 527 | minn="3"; 528 | if (minnn==4) 529 | minn="4"; 530 | if (minnn==5) 531 | minn="5"; 532 | if (minnn==6) 533 | minn="6"; 534 | if (minnn==7) 535 | minn="7"; 536 | if (minnn==8) 537 | minn="8"; 538 | if (minnn==9) 539 | minn="9"; 540 | setcolor(15); 541 | outtextxy(30,310,minn); 542 | setcolor(0); 543 | outtextxy(30,310,minn); 544 | } 545 | if (miles>99) 546 | { 547 | int minnn=miles%100; 548 | if (minnn==0) 549 | minn="0"; 550 | if (minnn==1) 551 | minn="1"; 552 | if (minnn==2) 553 | minn="2"; 554 | if (minnn==3) 555 | minn="3"; 556 | if (minnn==4) 557 | minn="4"; 558 | if (minnn==5) 559 | minn="5"; 560 | if (minnn==6) 561 | minn="6"; 562 | if (minnn==7) 563 | minn="7"; 564 | if (minnn==8) 565 | minn="8"; 566 | if (minnn==9) 567 | minn="9"; 568 | setcolor(15); 569 | outtextxy(40,310,minn); 570 | setcolor(0); 571 | outtextxy(40,310,minn); 572 | } 573 | if (miles>9) 574 | { 575 | int minnn=miles/10; 576 | if (minnn==0) 577 | minn="0"; 578 | if (minnn==1) 579 | minn="1"; 580 | if (minnn==2) 581 | minn="2"; 582 | if (minnn==3) 583 | minn="3"; 584 | if (minnn==4) 585 | minn="4"; 586 | if (minnn==5) 587 | minn="5"; 588 | if (minnn==6) 589 | minn="6"; 590 | if (minnn==7) 591 | minn="7"; 592 | if (minnn==8) 593 | minn="8"; 594 | if (minnn==9) 595 | minn="9"; 596 | setcolor(15); 597 | outtextxy(40,310,minn); 598 | setcolor(0); 599 | outtextxy(40,310,minn); 600 | } 601 | if (miles>9) 602 | { 603 | int minnn=miles%10; 604 | if (minnn==0) 605 | minn="0"; 606 | if (minnn==1) 607 | minn="1"; 608 | if (minnn==2) 609 | minn="2"; 610 | if (minnn==3) 611 | minn="3"; 612 | if (minnn==4) 613 | minn="4"; 614 | if (minnn==5) 615 | minn="5"; 616 | if (minnn==6) 617 | minn="6"; 618 | if (minnn==7) 619 | minn="7"; 620 | if (minnn==8) 621 | minn="8"; 622 | if (minnn==9) 623 | minn="9"; 624 | setcolor(15); 625 | outtextxy(50,310,minn); 626 | setcolor(0); 627 | outtextxy(50,310,minn); 628 | } 629 | if (miles<=9) 630 | { 631 | int minnn=miles; 632 | if (minnn==0) 633 | minn="0"; 634 | if (minnn==1) 635 | minn="1"; 636 | if (minnn==2) 637 | minn="2"; 638 | if (minnn==3) 639 | minn="3"; 640 | if (minnn==4) 641 | minn="4"; 642 | if (minnn==5) 643 | minn="5"; 644 | if (minnn==6) 645 | minn="6"; 646 | if (minnn==7) 647 | minn="7"; 648 | if (minnn==8) 649 | minn="8"; 650 | if (minnn==9) 651 | minn="9"; 652 | setcolor(15); 653 | outtextxy(40,310,minn); 654 | setcolor(0); 655 | outtextxy(40,310,minn); 656 | } 657 | if (flg==0) 658 | { 659 | randomize(); 660 | srand((unsigned) time(&ttt)); 661 | r=rand()%3; 662 | if (r==2) 663 | { 664 | randomize(); 665 | r1=random(10)%2; 666 | l=100; 667 | 668 | 669 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,5,6,7): 670 | c1.get(335,l+stage,405,l+stage-100,5,6,7); 671 | 672 | c1.draw(); 673 | flg=2; 674 | } 675 | } 676 | sound(miles+100); 677 | if (i==75) 678 | { 679 | c.get(k,j+100,k+70,j,0,0,0); 680 | c.draw(); 681 | k=200; 682 | c.get(k,j+100,k+70,j,4,3,8); 683 | if (flg==1) 684 | { 685 | c1.collide(14); 686 | c.collide(14); 687 | delay(500); 688 | c1.collide(0); 689 | c.collide(0); 690 | flg=3; 691 | T.timego(); 692 | } 693 | c.draw(); 694 | } 695 | if (i==155) 696 | { 697 | c.get(k,j+100,k+70,j,0,0,0); 698 | c.draw(); 699 | k=200; 700 | c.get(k,j+100,k+70,j,4,3,8); 701 | if (flg==1) 702 | { 703 | c1.collide(14); 704 | c.collide(14); 705 | delay(500); 706 | c1.collide(0); 707 | c.collide(0); 708 | flg=3; 709 | T.timego(); 710 | } 711 | c.draw(); 712 | } 713 | if (i==77) 714 | { 715 | c.get(k,j+100,k+70,j,0,0,0); 716 | c.draw(); 717 | k=335; 718 | c.get(k,j+100,k+70,j,4,3,8); 719 | if (flg==1) 720 | { 721 | c1.collide(14); 722 | c.collide(14); 723 | delay(500); 724 | c1.collide(0); 725 | c.collide(0); 726 | flg=3; 727 | T.timego(); 728 | } 729 | c.draw(); 730 | } 731 | if (i==157) 732 | { 733 | c.get(k,j+100,k+70,j,0,0,0); 734 | c.draw(); 735 | k=335; 736 | c.get(k,j+100,k+70,j,4,3,8); 737 | if (flg==1) 738 | { 739 | c1.collide(14); 740 | c.collide(14); 741 | delay(500); 742 | c1.collide(0); 743 | c.collide(0); 744 | T.timego(); 745 | flg=3; 746 | } 747 | c.draw(); 748 | } 749 | if (i==72) 750 | { 751 | mil+=1; 752 | track(t,0); 753 | (t>70)?t=-200:t+=5; 754 | track(t,15); 755 | if ((l+stage)>=200 && (l+stage)<=300) 756 | { 757 | if (r1==0 && k==200) 758 | { 759 | flg=1; 760 | 761 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0): 762 | c1.get(335,l+stage,405,l+stage-100,0,0,0); 763 | 764 | c1.draw(); 765 | } 766 | else if (r1==1 && k==335) 767 | { 768 | flg=1; 769 | 770 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0): 771 | c1.get(335,l+stage,405,l+stage-100,0,0,0); 772 | 773 | c1.draw(); 774 | } 775 | else 776 | flg=2; 777 | } 778 | if (flg==1) 779 | { 780 | c.collide(14); 781 | c1.collide(14); 782 | flg=0; 783 | delay(1000); 784 | c.collide(0); 785 | c1.collide(0); 786 | c.get(k,j+100,k+70,j,4,3,8); 787 | c.draw(); 788 | T.timego(); 789 | } 790 | if (flg==2) 791 | { 792 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0): 793 | c1.get(335,l+stage,405,l+stage-100,0,0,0); 794 | 795 | c1.draw(); 796 | l=l+5; 797 | 798 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,5,6,7) 799 | :c1.get(335,l+stage,405,l+stage-100,5,6,7); 800 | 801 | c1.draw(); 802 | if (l+stage>300) 803 | flg=3; 804 | } 805 | } 806 | if (i==152) 807 | { 808 | mil+=2; 809 | track(t,0); 810 | (t>70)?t=-200:t+=20; 811 | track(t,15); 812 | if (l+stage>=200 && l+stage<=300) 813 | { 814 | if (r1==0 && k==200) 815 | { 816 | flg=1; 817 | 818 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0): 819 | c1.get(335,l+stage,405,l+stage-100,0,0,0); 820 | 821 | c1.draw(); 822 | } 823 | else if (r1==1 && k==335) 824 | { 825 | flg=1; 826 | 827 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0): 828 | c1.get(335,l+stage,405,l+stage-100,0,0,0); 829 | 830 | c1.draw(); 831 | } 832 | else 833 | flg=2; 834 | } 835 | if (flg==1) 836 | { 837 | c.collide(14); 838 | c1.collide(14); 839 | flg=0; 840 | delay(1000); 841 | c.collide(0); 842 | c1.collide(0); 843 | c.get(k,j+100,k+70,j,4,3,8); 844 | c.draw(); 845 | T.timego(); 846 | } 847 | if (flg==2) 848 | { 849 | 850 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0) 851 | :c1.get(335,l+stage,405,l+stage-100,0,0,0); 852 | 853 | c1.draw(); 854 | l+=10; 855 | 856 | 857 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,5,6,7) 858 | :c1.get(335,l+stage,405,l+stage-100,5,6,7); 859 | 860 | c1.draw(); 861 | if (l+stage>300) 862 | flg=3; 863 | } 864 | } 865 | if (i==80) 866 | { 867 | mil-=1; 868 | track(t,0); 869 | (t<-370)?t=-200:t-=5; 870 | track(t,15); 871 | if (l+stage>=200 && l+stage<=300) 872 | { 873 | if (r1==0 && k==200) 874 | { 875 | flg=1; 876 | 877 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0) 878 | :c1.get(335,l+stage,405,l+stage-100,0,0,0); 879 | 880 | c1.draw(); 881 | } 882 | else if (r1==1 && k==335) 883 | { 884 | flg=1; 885 | 886 | 887 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0) 888 | :c1.get(335,l+stage,405,l+stage-100,0,0,0); 889 | 890 | c1.draw(); 891 | } 892 | else 893 | flg=2; 894 | } 895 | if (flg==1) 896 | { 897 | c.collide(14); 898 | c1.collide(14); 899 | flg=0; 900 | delay(1000); 901 | c.collide(0); 902 | c1.collide(0); 903 | c.draw(); 904 | T.timego(); 905 | } 906 | if (flg==2) 907 | { 908 | 909 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0) 910 | :c1.get(335,l+stage,405,l+stage-100,0,0,0); 911 | 912 | c1.draw(); 913 | l=l-5; 914 | 915 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,5,6,7) 916 | :c1.get(335,l+stage,405,l+stage-100,5,6,7); 917 | 918 | c1.draw(); 919 | if (l+stage>300) 920 | flg=3; 921 | } 922 | } 923 | if (i==160) 924 | { 925 | mil-=2; 926 | track(t,0); 927 | (t<-370)?t=-200:t-=20; 928 | track(t,15); 929 | if (l+stage>=200 && l+stage<=300) 930 | { 931 | if (r1==0 && k==200) 932 | { 933 | flg=1; 934 | 935 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0) 936 | :c1.get(335,l+stage,405,l+stage-100,0,0,0); 937 | 938 | c1.draw(); 939 | } 940 | else if (r1==1 && k==335) 941 | { 942 | flg=1; 943 | 944 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0) 945 | :c1.get(335,l+stage,405,l+stage-100,0,0,0); 946 | 947 | c1.draw(); 948 | } 949 | else 950 | flg=2; 951 | } 952 | if (flg==1) 953 | { 954 | c.collide(14); 955 | c1.collide(14); 956 | flg=0; 957 | delay(1000); 958 | c.collide(0); 959 | c1.collide(0); 960 | c.draw(); 961 | T.timego(); 962 | } 963 | if (flg==2) 964 | { 965 | 966 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0) 967 | :c1.get(335,l+stage,405,l+stage-100,0,0,0); 968 | 969 | c1.draw(); 970 | l=l-10; 971 | 972 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,5,6,7) 973 | :c1.get(335,l+stage,405,l+stage-100,5,6,7); 974 | 975 | c1.draw(); 976 | if (l+stage>300) 977 | flg=3; 978 | } 979 | } 980 | if (flg==3) 981 | { 982 | 983 | (r1==0)?c1.get(200,l+stage,270,l+stage-100,0,0,0) 984 | :c1.get(335,l+stage,405,l+stage-100,0,0,0); 985 | 986 | c1.draw(); 987 | flg=0; 988 | } 989 | if (i==32) 990 | { 991 | sound(2000); 992 | delay(200); 993 | } 994 | nosound(); 995 | if (mil>4) 996 | { 997 | miles+=1; 998 | mil=0; 999 | } 1000 | if (mil<-4) 1001 | { 1002 | miles-=1; 1003 | mil=0; 1004 | } 1005 | if (miles>=1000) 1006 | break; 1007 | }while(i!='\r'); 1008 | if (miles>=1000) 1009 | { 1010 | sound(3000); 1011 | clearviewport(); 1012 | settextstyle(8,0,1); 1013 | int i=T.minutes(); 1014 | if (i<8) 1015 | outtextxy(50,100,"CONGRATULATIONS! \ 1016 | You have won the competetion"); 1017 | else 1018 | outtextxy(50,100,"SORRY! You fell \ 1019 | out of time"); 1020 | delay(1000); 1021 | getch(); 1022 | nosound(); 1023 | } 1024 | } -------------------------------------------------------------------------------- /dowhile.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | do{ 8 | cout<>n; 10 | } while(n>0); 11 | 12 | return 0; 13 | } -------------------------------------------------------------------------------- /even_odd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | bool a=1; 6 | int num=3; 7 | for(int i=1;i<=num;i++) 8 | { 9 | a=!a; 10 | } 11 | if(a) 12 | { 13 | printf("Even"); 14 | } 15 | else 16 | { 17 | printf("odd"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /favicon_io/about.txt: -------------------------------------------------------------------------------- 1 | This favicon was generated using the following font: 2 | 3 | - Font Title: Charm 4 | - Font Author: Copyright 2018 The Charm Project Authors (https://github.com/cadsondemak/charm) 5 | - Font Source: http://fonts.gstatic.com/s/charm/v10/7cHmv4oii5K0MeYvIe804WIo.ttf 6 | - Font License: SIL Open Font License, 1.1 (http://scripts.sil.org/OFL)) 7 | -------------------------------------------------------------------------------- /favicon_io/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariom20singh/car-racing-game/6c3389f2342535ccf0b87b8055662334eb20b23f/favicon_io/android-chrome-192x192.png -------------------------------------------------------------------------------- /favicon_io/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariom20singh/car-racing-game/6c3389f2342535ccf0b87b8055662334eb20b23f/favicon_io/android-chrome-512x512.png -------------------------------------------------------------------------------- /favicon_io/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariom20singh/car-racing-game/6c3389f2342535ccf0b87b8055662334eb20b23f/favicon_io/apple-touch-icon.png -------------------------------------------------------------------------------- /favicon_io/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariom20singh/car-racing-game/6c3389f2342535ccf0b87b8055662334eb20b23f/favicon_io/favicon-16x16.png -------------------------------------------------------------------------------- /favicon_io/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariom20singh/car-racing-game/6c3389f2342535ccf0b87b8055662334eb20b23f/favicon_io/favicon-32x32.png -------------------------------------------------------------------------------- /favicon_io/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariom20singh/car-racing-game/6c3389f2342535ccf0b87b8055662334eb20b23f/favicon_io/favicon.ico -------------------------------------------------------------------------------- /favicon_io/site.webmanifest: -------------------------------------------------------------------------------- 1 | {"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} -------------------------------------------------------------------------------- /fibnum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int fibonacci_fast(int n) 4 | { 5 | // write your code here 6 | int F[n + 1]; 7 | F[0] = 0; 8 | F[1] = 1; 9 | for (int i = 2; i < n + 2; i++) 10 | { 11 | F[i] = F[i - 1] + F[i - 2]; 12 | } 13 | 14 | return F[n]; 15 | } 16 | 17 | int main(){ 18 | int n; 19 | cin>>n; 20 | cout< 2 | using namespace std; 3 | int sum(int a,int b){ 4 | return a+b; 5 | } 6 | int sum(int a,int b,int c){ 7 | return a+b+c; 8 | } 9 | int main(){ 10 | int a,b,c; 11 | cin>>a>>b>>c; 12 | cout< 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Weather App 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Weather App 21 | 22 | 23 | 24 | 25 |
26 | 27 |
28 | 29 |
30 |

Weather Web App

31 |
32 |
33 | 34 |
35 | 36 | 37 |
38 |

Demo City

39 |
40 |
41 |

Demo weather type

42 |
    43 |
  • Temp: --F
  • 44 |
  • Min Temp: --F
  • 45 |
  • Max Temp: --F
  • 46 |
47 |
48 | 49 | 50 | 51 | 52 |
53 | 54 | 55 |
56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /intersection_of_two_arrays.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void intersection(int *input1, int *input2, int size1, int size2) 5 | { 6 | for(int i=0; i> t; 25 | while (t--) 26 | { 27 | 28 | int size1, size2; 29 | 30 | cin >> size1; 31 | int *input1 = new int[size1]; 32 | 33 | for (int i = 0; i < size1; i++) 34 | { 35 | cin >> input1[i]; 36 | } 37 | 38 | cin >> size2; 39 | int *input2 = new int[size2]; 40 | 41 | for (int i = 0; i < size2; i++) 42 | { 43 | cin >> input2[i]; 44 | } 45 | 46 | intersection(input1, input2, size1, size2); 47 | 48 | delete[] input1; 49 | delete[] input2; 50 | 51 | cout << endl; 52 | } 53 | return 0; 54 | } -------------------------------------------------------------------------------- /mallu.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a=5; 6 | int b=2; 7 | int c=a/b; 8 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int i,n; 6 | cin>>n; 7 | int sum=0; 8 | for(i=0;i 2 | #include 3 | using namespace std; 4 | 5 | // int main(int argc, char const *argv[]) 6 | // { 7 | // int n ; 8 | // cin>>n; 9 | // int array [n]; 10 | // for (int i = 0; i >array[i]; 13 | // } 14 | // for (int i = 0; i <= n; i++) 15 | // { 16 | // cout<> n; 26 | // int array[n]; 27 | // for (int i = 0; i < n; i++) 28 | // { 29 | // cin >> array[i]; 30 | // } 31 | // int min = INT_MAX; 32 | // int max = INT_MIN; 33 | // for (int i = 0; i < n; i++) 34 | // { 35 | // if (array[i]max) 40 | // { 41 | // max =array[i]; 42 | // } 43 | 44 | // } 45 | // cout<>n; 69 | // int arr[n]; 70 | // for(int i = 0 ; i >arr[i]; 73 | // } 74 | // int key ; 75 | // cin>>key; 76 | // cout<arr[j]) 86 | // { 87 | // int temp = arr[j]; 88 | // arr[j]=arr[i]; 89 | // arr[i]=temp; 90 | // } 91 | // } 92 | // cout<> n; 100 | // int arr[n]; 101 | // for (int i = 0; i < n; i++) 102 | // { 103 | // cin >> arr[i]; 104 | // } 105 | // cout<> n; 115 | 116 | // int arr[n]; 117 | // for (int i = 0; i < n; i++) 118 | // { 119 | // cin >> arr[i]; 120 | // } 121 | // for (int i = 0; i < n; i++) 122 | // { 123 | // for (int j = i; j < n; j++) 124 | // { 125 | // if (arr[i] > arr[j]) 126 | // { 127 | // int temp = arr[j]; 128 | // arr[j] = arr[i]; 129 | // arr[i] = temp; 130 | // } 131 | 132 | // } 133 | // cout << arr[i] << " "; 134 | // } 135 | 136 | // return 0; 137 | // } 138 | 139 | // insertion sort 140 | 141 | // int main(int argc, char const *argv[]) 142 | // { 143 | 144 | 145 | // int n ; 146 | // cin>>n; 147 | // int arr[n]; 148 | // for(int i = 0 ; i >arr[i]; 151 | 152 | // } 153 | // int mx = INT16_MIN; 154 | // int minn = INT16_MAX; 155 | // for(int i = 0 ; i >n; 184 | // int arr[n]; 185 | // for(int i = 0 ; i>arr[i]; 188 | // } 189 | // int key ; 190 | // cin>>key; 191 | 192 | // cout< 2 | #include 3 | 4 | void update(int *a,int *b) 5 | { 6 | // Complete this function 7 | int x, y; 8 | // Complete this function 9 | x = *a + *b ; 10 | y = *a - *b ; 11 | *a = x; 12 | *b = abs(y); 13 | 14 | } 15 | 16 | int main() 17 | { 18 | int a, b; 19 | int *pa = &a, *pb = &b; 20 | 21 | scanf("%d %d", &a, &b); 22 | update(pa, pb); 23 | printf("%d\n%d", a, b); 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /project.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Example of How to Create Browsers Window using HTML and CSS? 8 | 10 | 11 | 130 | 131 |

Example

132 |

How to Create Browsers Window using HTML and CSS?

133 |
134 |
135 |
136 | 138 |
139 |
140 | 141 | 143 |
144 |
145 |
146 | 147 | 148 | 149 |
150 |
151 |
152 |
153 |

J avatpoint

154 |

A Computer Science Portal providing Online Training for Web Development Courses

155 |
156 |
157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | Example of How to Create Browsers Window using HTML and CSS? 165 | 167 | 168 | 287 | 288 |

Example

289 |

How to Create Browsers Window using HTML and CSS?

290 |
291 |
292 |
293 | 295 |
296 |
297 | 298 | 300 |
301 |
302 |
303 | 304 | 305 | 306 |
307 |
308 |
309 |
310 |

J avatpoint

311 |

A Computer Science Portal providing Online Training for Web Development Courses

312 |
313 |
314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | Example of How to Create Browsers Window using HTML and CSS? 322 | 324 | 325 | 444 | 445 |

Example

446 |

How to Create Browsers Window using HTML and CSS?

447 |
448 |
449 |
450 | 452 |
453 |
454 | 455 | 457 |
458 |
459 |
460 | 461 | 462 | 463 |
464 |
465 |
466 |
467 |

J avatpoint

468 |

A Computer Science Portal providing Online Training for Web Development Courses

469 |
470 |
471 | 472 | -------------------------------------------------------------------------------- /queue.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct CircularQueue 5 | { 6 | int size; 7 | int f; 8 | int r; 9 | int *arr; 10 | }; 11 | 12 | int IsFull(struct CircularQueue *q) 13 | { 14 | if ((q->r+1)%q->size == q->f) 15 | { 16 | return 1; 17 | } 18 | return 0; 19 | } 20 | int IsEmpty(struct CircularQueue *q) 21 | { 22 | if (q->f == q->r) 23 | { 24 | return 1; 25 | } 26 | return 0; 27 | } 28 | 29 | // enqueue operation 30 | void enqueue(struct CircularQueue *q, int val) 31 | { 32 | if (IsFull(q)) 33 | { 34 | printf("Queue is Full \n"); 35 | } 36 | else 37 | { 38 | q->r = (q->r + 1)%q->size; 39 | q->arr[q->r] = val; 40 | printf("Enque Element %d \n" , val); 41 | } 42 | } 43 | 44 | // dequeue operation 45 | int dequeue(struct CircularQueue *q) 46 | { 47 | int a = -1; 48 | if (IsEmpty(q)) 49 | { 50 | printf("This queue is Empty\n"); 51 | } 52 | else 53 | { 54 | q->f=(q->f+1)%q->size; 55 | a = q->arr[q->f]; 56 | } 57 | return a; 58 | } 59 | 60 | int main() 61 | { 62 | struct CircularQueue q; 63 | q.size = 4; 64 | q.f = q.r = 0; 65 | q.arr = (int *)malloc(q.size * sizeof(int)); 66 | 67 | // Enqueue few element 68 | enqueue(&q, 234); 69 | enqueue(&q, 889); 70 | enqueue(&q, 35); 71 | // enqueue(&q, 37); 72 | 73 | printf("dequeue of Element:- %d \n", dequeue(&q)); 74 | printf("dequeue of Element:- %d \n", dequeue(&q)); 75 | printf("dequeue of Element:- %d \n", dequeue(&q)); 76 | 77 | enqueue(&q, 300); 78 | 79 | if (IsEmpty(&q)) 80 | { 81 | printf("Queue is Empty! \n"); 82 | } 83 | else 84 | { 85 | printf("Queue is not empty! \n"); 86 | } 87 | if (IsFull(&q)) 88 | { 89 | printf("Queue is Full! \n"); 90 | } 91 | else 92 | { 93 | printf("Queue is not Full! \n"); 94 | } 95 | 96 | return 0; 97 | } 98 | -------------------------------------------------------------------------------- /queue_using_array.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct queue{ 5 | int size; 6 | int f; 7 | int r; 8 | int* arr; 9 | }; 10 | 11 | int IsFull(struct queue *q){ 12 | if(q->r==q->size-1) 13 | { 14 | return 1; 15 | } 16 | return 0; 17 | 18 | } 19 | int IsEmpty(struct queue *q){ 20 | if(q->f==q->r){ 21 | return 1; 22 | } 23 | return 0; 24 | } 25 | 26 | // enqueue operation 27 | void enqueue(struct queue* q,int val){ 28 | if(IsFull(q)){ 29 | printf("Queue is overloading \n"); 30 | } 31 | else{ 32 | q->r=q->r+1; 33 | q->arr[q->r]=val; 34 | } 35 | } 36 | 37 | //dequeue operation 38 | int dequeue(struct queue *q){ 39 | int a= -1; 40 | if(IsEmpty(q)){ 41 | printf("This queue is Empty\n"); 42 | } 43 | else{ 44 | q->f++; 45 | a=q->arr[q->f]; 46 | } 47 | return a; 48 | } 49 | 50 | int main(){ 51 | struct queue q; 52 | q.size = 3; 53 | q.f = q.r=-1; 54 | q.arr = (int *)malloc(q.size * sizeof(int)); 55 | 56 | // Enqueue few element 57 | enqueue(&q, 234); 58 | enqueue(&q, 889); 59 | enqueue(&q, 35); 60 | // enqueue(&q, 37); 61 | 62 | printf("dequeue of Element:- %d \n",dequeue(&q)); 63 | printf("dequeue of Element:- %d \n",dequeue(&q)); 64 | printf("dequeue of Element:- %d \n",dequeue(&q)); 65 | 66 | if(IsEmpty(&q)){ 67 | printf("Queue is Empty! \n"); 68 | } 69 | else{ 70 | printf("Queue is not empty! \n"); 71 | 72 | } 73 | if(IsFull(&q)){ 74 | printf("Queue is Full! \n"); 75 | } 76 | else{ 77 | printf("Queue is not Full! \n"); 78 | 79 | } 80 | 81 | 82 | return 0; 83 | } -------------------------------------------------------------------------------- /script.js: -------------------------------------------------------------------------------- 1 | const options = { 2 | method: 'GET', 3 | headers: { 4 | 'X-RapidAPI-Key': '6e76919c8dmsh8c4a6a67eedd7cap19a1c9jsnf1f90150cce3', 5 | 'X-RapidAPI-Host': 'yahoo-weather5.p.rapidapi.com' 6 | } 7 | }; 8 | // city = 'mumbai' 9 | const getweatherData = (city)=>{ 10 | 11 | const weatherPromise = fetch(`https://yahoo-weather5.p.rapidapi.com/weather?location=${city}&format=json&u=f`, options) 12 | return weatherPromise.then((response) => { 13 | return response.json(); 14 | }) 15 | } 16 | 17 | const searchCity=()=>{ 18 | city = document.getElementById('input-city').value 19 | // console.log(city) 20 | const weatherdata = getweatherData(city) 21 | weatherdata.then(data=>{ 22 | console.log(data['location'].city) 23 | showWeather(data) 24 | 25 | }) 26 | 27 | } 28 | const showWeather=(weatherdata)=>{ 29 | console.log(weatherdata) 30 | document.getElementById("city-name").innerText = weatherdata['location'].city; 31 | document.getElementById("weather-type").innerText = weatherdata.current_observation.condition.text; 32 | document.getElementById("temp").innerText = weatherdata.current_observation.condition.temperature; 33 | document.getElementById("min-temp").innerText = weatherdata.forecasts[0].low; 34 | document.getElementById("max-temp").innerText = weatherdata.forecasts[0].high; 35 | } 36 | 37 | // let api_key='6e76919c8dmsh8c4a6a67eedd7cap19a1c9jsnf1f90150cce3' 38 | // const getWeatherData=async (city)=>{ 39 | // const url = `https://yahoo-weather5.p.rapidapi.com/weather?location=${city}&format=json&u=f` 40 | // const weatherPromises = fetch(url) 41 | // const response = await weatherPromises; 42 | // return await response.json(); 43 | // } 44 | // const searchCity=()=>{ 45 | // const city ='mumbai' 46 | // // const city= document.getElementById('input-city').value 47 | // const weatherdata = getWeatherData(city) 48 | // weatherdata.then(data=>{ 49 | // console.log(data['location'].city) 50 | // }) 51 | 52 | // } 53 | // searchCity() -------------------------------------------------------------------------------- /sndkfne.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | printf("Hello World"); 6 | 7 | return 0 ; 8 | } -------------------------------------------------------------------------------- /student_marks.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class student 4 | { public: 5 | 6 | string str; 7 | int rollno; 8 | string st; 9 | int arr[5]; 10 | void input() 11 | { 12 | cout<<"Enter Your Name : "; 13 | getline(cin,str); 14 | 15 | cout<<"Enter Your Roll Number : "; 16 | cin>>rollno; 17 | 18 | cout<<"Enter Your Standard : "; 19 | cin>>st; 20 | 21 | for(int i=0;i<5;i++) 22 | { cout<<"Enter your "<>arr[i]; 24 | } 25 | } 26 | 27 | int tmarks=0; 28 | int avermarks; 29 | double per; 30 | void calculate() 31 | { 32 | 33 | for(int i=0;i<5;i++) 34 | { 35 | tmarks+=arr[i]; 36 | } 37 | avermarks=tmarks/5; 38 | per=tmarks/5; 39 | 40 | } 41 | 42 | void display() 43 | { 44 | cout<<"Your Name is : "<33.0) 51 | cout<<"You Are PASS with "< 2 | int main() 3 | { 4 | int age ; 5 | printf("Enter the age:\n"); 6 | scanf("%d", &age); 7 | switch (age) 8 | { 9 | case 3 : 10 | printf(" your age is 3 "); 11 | break; 12 | 13 | default: 14 | printf("your age is not 3,4, and 23 "); 15 | break; 16 | } 17 | return 0 ; 18 | 19 | 20 | } -------------------------------------------------------------------------------- /tut8.html.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |

This is HTML forms tutorial

11 |
12 | Name 13 |
14 | 15 |
16 |
17 |
18 | Role: 19 |
20 |
21 |
22 | Email: 23 |
24 |
25 |
26 | 27 |
28 |
29 |
30 | Bonus: 31 |
32 |
33 |
34 | Are you eligible?: 35 |
36 |
37 |
38 | Gender:Male FeMale 39 | other: 40 |
41 |
42 | write about yourself: