This file contains 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
%% | |
"the" {yylval=1; return(ARTICLE);} | |
"a" {yylval=2; return(ARTICLE);} | |
"dog" {yylval=3; return(NOUN);} | |
"cat" {yylval=4; return(NOUN);} | |
"man" {yylval=5; return(NOUN);} | |
"woman" {yylval=6; return(NOUN);} | |
"robot" {yylval=7; return(NOUN);} | |
"bit" {yylval=8; return(VERB);} |
This file contains 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
jImej bang | |
wIDanlu'taHvIS, 'op po jIvempu', | |
'o jImej bang, jImej bang, jImej bang, bang, bang! | |
wIDanlu'taHvIS, 'op po jIvempu', | |
muDech yotwI'pu' 'e' vItu'. | |
'o lotlhbogh SuvwI', qatlhej vIneHbej | |
'o jImej bang, jImej bang, jImej bang, bang, bang! | |
'o lotlhbogh SuvwI', qatlhej vIneHbej |
This file contains 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
/* | |
* | |
Stacking Cups | |
You are programming a cup stacking module for your robot. This robot is equiped with several sensors that can accurately determine the radius and color of a cup. The problem is that there is a glitch in the robot’s core routine that processess sensor inputs so the radius is doubled, if the result of the color sensor arrives to the routine after the radius. | |
For instance, for a red cup with a radius of 5 units, your module will receive either "red 5" or "10 red" message. | |
Given a list of messages from the core routine, each describing a different cup, can you put the cups in order of the smallest to the largest? |
This file contains 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
#include <stdio.h> | |
#include <string.h> | |
//moved the fixed sizes to defines and have 2. 1 for the main buffer, and one for the name fields | |
#define maxinput 256 | |
#define maxname 16 | |
int main() | |
{ | |
char input[maxinput];//large buffer to accept more input than name fields allow - note that too can overflow as the value is fixed |
This file contains 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
#include <stdio.h> | |
int clean_stdin() | |
{ | |
while (getchar()!='\n'); | |
return 1; | |
} | |
int main(void) | |
{ |
This file contains 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
/* | |
* keep_the_change_ya_filthy_animal.c | |
* low tech variable based approach | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
This file contains 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
/*This program will read characters from a file, and for each line: | |
* print it, followed by the count of the characters in that line.*/ | |
#include <stdio.h> | |
int main(void) | |
{ | |
char filename[]="testinputfile.txt"; | |
/*This is a pointer that will point to the file (a single point in the file, not a whole line). |
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <time.h> | |
/*Processes the input file*/ | |
int process_file(void) | |
{ |
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <math.h> | |
#include <limits.h> | |
#include <time.h> | |
/*Finds length of longest line in file*/ | |
int charcount(char *filename) |
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <ctype.h> | |
#include <string.h> | |
#include <limits.h> | |
/*Finds length of longest line in file*/ | |
int charcount(char *filename) | |
{ |