Last active
August 29, 2015 14:16
-
-
Save 98chimp/593847eb53ee153d423c to your computer and use it in GitHub Desktop.
Adam
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.c | |
// Adam | |
// | |
// Created by Shahin on 2015-03-09. | |
// Copyright (c) 2015 98% Chimp. All rights reserved. | |
// | |
#include <stdio.h> | |
#include <stdbool.h> | |
#include <ctype.h> | |
#include <string.h> | |
int main(int argc, const char * argv[]) { | |
// insert code here... | |
while (1) { | |
printf("Please type in your question for Adam (type exit to discontinue): "); | |
char input[]=""; | |
rewind(stdin); | |
scanf("%[^\n]", input); | |
long length = strlen(input); | |
long len = length - 1; | |
char *s1 = &input[len]; | |
char *s2 = "?"; | |
char *exit = "exit"; | |
bool uppercase = true; | |
if (strcmp(input, exit) == 0) { | |
printf("Yo yo!\n"); | |
break; | |
} | |
else if (length > 0) { | |
for (int i = 0; i < length; i++) { | |
if (!((input[i] >= 65 && input[i] <= 90) || input[i] == 32)) { | |
uppercase = false; | |
break; | |
} | |
} | |
if (uppercase) { | |
printf("Woah, chill out!\n"); | |
} | |
else if (strcmp(s1, s2) == 0) { | |
printf("Sure!\n"); | |
} | |
else { | |
printf("Whatever!\n"); | |
} | |
} | |
else { | |
printf("Fine. Be that way!\n"); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment