Round G 2022 - Kick Start 2022 Walktober Problem (C Code)

// Below is the Solution of the Round G 2022 -kickstart 2022 :) 

// Contact me if any question persist in your mind, I'm ready to help you :) 

// HAPPY CODING

#include <stdio.h>

int main(){

    int t,count=0;

    scanf("%d",&t);

    while(t--){

        int M,N,P,k=0,i,j;

        scanf("%d%d%d",&M,&N,&P);

        int max[N],pl[N],n[N];

        for(i=0;i<N;i++)

        max[i]=0;

        for(i=0;i<M;i++){

            for(j=0;j<N;j++){

                scanf("%d",&n[j]);

                if((i+1)!=P){

                if(max[j]<n[j])

                max[j]=n[j];

                }

                else{

                    pl[j]=n[j];

                }

            }

        }

        int ans=0;

        for(i=0;i<N;i++){

            if(max[i]>pl[i])

            ans+=(max[i]-pl[i]);

            else

            ans+=0;

        }

        printf("Case #%d: %d\n",++count,ans);

    }

    return 0;

}

Program to print the smallest word in an sentence (Coding Ninja Solutions)

#include <stdio.h>

#include <string.h> // Here I've to add this header file for strcat() function

int main() {

    char name[]="Vaibhav Yadav is good boy";

    char ccname[]=" "; // This is to add space at the end of sentence so that condition can read it.

    strcat(name,ccname); // this functions append the space to last character

    int i,j,k,min=50,count=0;

    for(i=0;name[i]!='\0';i++){

        if(name[i]!=' '){

        count++;

        }

        else{

            if(count<min)

            {

                min=count;

                k  = i;

                k-=count;

            }

                count=0;

        }

    }

    

    // printf("%d ",min);

    for(i=k;name[i]!=' ';i++)

    printf("%c",name[i]);

    k = 0;

    return 0;

}

ROCK PAPER SCISSOR GAME BUILD USING HTML, CSS and Javascript


 This Rock Paper Scissor Game Build Using HTML CSS and Javascript .

Click Here to View the live website

Click Here to view the original source code at github

Below is the Source Code of Above game

<!--------------------------------- HTML CODE ------------------------->

<!DOCTYPE html>

<html lang="en">

<head>

    <link rel="stylesheet" href="style.css">

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Rockpaperscissor</title>

</head>

<body>

    <div class="container">

        <button class="game" value="Rock">✊</button>

        <button class="game" value="Paper">✋</button>

        <button class="game" value="Scissors">✌</button>

        <div class="showresult">

        <p id="player-score"></p>

        <p id="hands"></p>

        <p id="result"></p>

        </div>

        <button class="reset games" id="endGameButton">🔴</button>

    </div>

    <script src="javascr.js"></script>

    <footer>Made By Vaibhav Yadav with ❤❤</footer>

</body>

</html>

//                                    Javascript Code 

const totalscore = { computerScore: 0, playerScore: 0}


function getcomputerchoice() {

    const rpschoice = ['Rock','Paper','Scissors']

    const randomnumber = Math.floor( Math.random()*3 )

    return rpschoice[randomnumber]

}

function getResult(playerChoice, computerChoice) {

    let score;

    if( playerChoice == computerChoice){ 

    score = 0

    totalscore['computerScore']+= 0

    }

    else if ( playerChoice == 'Rock' && computerChoice == 'Scissors'){

        score = 1

    }

    else if ( playerChoice == 'Paper' && computerChoice == 'Rock'){

        score = 1

    } else if ( playerChoice == 'Scissors' && computerChoice == 'Paper'){

        score = 1

    }

    else{

       score = -1

       totalscore['computerScore']+= 1

 }

    return score

}

function showresult(score,playerChoice,computerChoice)

{

    const resultdiv = document.getElementById('result')

    const handdiv = document.getElementById('hands')

    const playerscorediv = document.getElementById('player-score')

    if(score == -1 ) {

        resultdiv.innerText = "You Lose"

    }

    else if(score == 0 ){

        resultdiv.innerText = "It's a tie"

    }

    else{

        resultdiv.innerText = "You Win"

    }

    handdiv.innerText = "Computer Choice is: " + computerChoice

    playerscorediv.innerText =  "Your Score is : " + totalscore["playerScore"] + "  Computer Score is : " +totalscore["computerScore"]

    

}

function onClickgames(playerChoice){

    // console.log({playerChoice})

    const computerChoice = getcomputerchoice()

    // console.log({computerChoice})

    const score = getResult(playerChoice, computerChoice)

    totalscore['playerScore'] += score

    // console.log({score})

    // console.log(totalscore) 

    showresult(score,playerChoice,computerChoice)

}

function playGame(){

    const games = document.querySelectorAll('.game')

    // games[0].onclick = () => alert(games[0].value)

    

    games.forEach(game => {

        game.onclick = () => onClickgames(game.value)

    })

}

const endgamebutton = document.getElementById("endGameButton")

endgamebutton.onclick = () =>endgame(totalscore)

function endgame(totalscore)

{

    totalscore['playerScore'] = 0

    totalscore['computerScore'] = 0


    const resultdiv = document.getElementById('result')

    const handdiv = document.getElementById('hands')

    const playerscorediv = document.getElementById('player-score')


    resultdiv.innerText = ''

    handdiv.innerText = ''

    playerscorediv.innerText = ''

}

playGame()

/*                              CSS CODE                    */

body{

    background-color: black;

    margin: 0;

    padding: 0;

    font-weight: bolder;

    font-family: sans-serif;

}

.container{

    border-radius: 4%;

    box-shadow: 10px 10px 50px black;

    padding: 2vh;

    width: 80vh;

    text-align: center;

    background-color: steelblue;

    margin: 20vh auto;

}

.container button{

    background-color: transparent;

    border: none;

    

    margin: 3vh;

}

.game {

    box-shadow: 5px 5px 9px black;

    border-radius: 9%;

    /* background-color: red; */

    font-size: 70px;

    cursor: pointer;

}

.reset{

    

    font-size: 50px;

    margin: 9vh 0 0 31vh;

    width: 20vh;

}

/* .container span:hover { 

    transform: rotate(-40deg);

} */

.showresult{

    padding: 2px;

    border-radius: 9px;

    box-shadow: 5px 5px 13px black;

}

.showresultnone{

    height: 0;

    display: none;

}

.games{

    box-shadow: 5px 5px 9px black;

    border-radius: 9%;

    /* background-color: red; */

    font-size: 70px;

    cursor: pointer;

}

button:active{

    transform: translate(2px, 2px);

}

footer{

    text-align: center;

    background-color: wheat;


Operator Overloading in C++

#include<iostream> using namespace std; class Complex { private: int real, imag; public: Complex(int r = 0, int i = 0){       re...