Commit e1fa4486 authored by Hermann Krumrey's avatar Hermann Krumrey
Browse files

Imported project into git repository

parents
Loading
Loading
Loading
Loading
+44 −0
Changes for Rock Paper Scissors/Rock Paper Scissors.cbp: 44 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="Rock Paper Scissors" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin/Debug/Rock Paper Scissors" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Debug/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-g" />
				</Compiler>
			</Target>
			<Target title="Release">
				<Option output="bin/Release/Rock Paper Scissors" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Release/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-O2" />
				</Compiler>
				<Linker>
					<Add option="-s" />
				</Linker>
			</Target>
		</Build>
		<Compiler>
			<Add option="-Wall" />
		</Compiler>
		<Unit filename="main.c">
			<Option compilerVar="CC" />
		</Unit>
		<Extensions>
			<code_completion />
			<envvars />
			<debugger />
			<lib_finder disable_auto="1" />
		</Extensions>
	</Project>
</CodeBlocks_project_file>
+8 −0
Changes for Rock Paper Scissors/Rock Paper Scissors.depend: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
# depslib dependency file v1.0
1395424367 source:c:\users\hermann\skydrive\c\rock paper scissors\main.c
	<stdio.h>
	<stdlib.h>
	<ctype.h>
	<string.h>
	<time.h>
+9 −0
Changes for Rock Paper Scissors/Rock Paper Scissors.layout: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
	<ActiveTarget name="Debug" />
	<File name="main.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
		<Cursor>
			<Cursor1 position="3374" topLine="0" />
		</Cursor>
	</File>
</CodeBlocks_layout_file>
+30.6 KiB

File added.

No diff preview for this file type.

+56 −0
Changes for Rock Paper Scissors/main.c: 56 added lines, 0 removed lines.
Original line number Diff line number Diff line
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>

int main(){
    printf("Welcome to Rock Paper Scissors!\n\n");                                                      //Introduction

    int wloop1 = 0;                                                                                     //loop initiator 1
    while(wloop1==0){                                                                                   //while loop 1

        int wloop2 = 0;                                                                                 //loop initiator 2
        while(wloop2==0){                                                                               //while loop 2

            printf("Do you choose ROCK, PAPER, or SCISSORS?\n");                                        //print user prompt
            char user[256];                                                                             //define user variable
            scanf("%s", user);                                                                          //scan keyboard for user input
            //printf("%s", user);                                                                       //check userinput
            int i = 0;                                                                                  //initiate toupper loop
            while(user[i]){                                                                             //beginn toupper loop, end when at end of user-string
                user[i] = toupper(user[i]);                                                             //toupper function
                i++;                                                                                    //increment i
            }
            //printf("%s", user);                                                                       //check userinput again
            if(strncmp(user,"ROCK",4)==0||strncmp(user,"PAPER",5)==0||strncmp(user,"SCISSORS",4)==0){   //check if input is valid
                printf("\nInput is %s\n", user);                                                        //Input analysis
                wloop2 = 1;                                                                             //loop 2 ender
            }
            else{                                                                                       //condition to continue loop 2
                printf("\nInput faulty\n");                                                             //output error message and continue loop 2
            }
        }

        srand(time(0));                                                                              //create random seed
        int random = rand() % 99 + 1;                                                                   //initiate random number between 1 and 100

        char comp[255];                                                                                   //Initiate PC choice variable
        if(random<34){                                                                                  //creation of random PC input
            comp[255] = "ROCK";
        }
        else{if(random<67){
                comp[255] = "PAPER";
            }
            else{
                comp[255] = "SCISSORS";
            }
        }

        printf("PC %s", comp);                                                                    //check PC input



        wloop1 = 0;                                                                                     //loop 1 ender
    }
}
Loading