Commit e1fa4486 authored by Hermann Krumrey's avatar Hermann Krumrey

Imported project into git repository

parents
<?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>
# 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>
<?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>
#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
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment