User Tools

Site Tools


labs

This is an old revision of the document!


LAB 1

Please check the tutorial at Unix Tutorial for Beginners

Lab 1 Lab 1

As I mentioned in the class, C is similar to java. Here is an example of a c code that reads an integer and prints it.

#include <stdio.h>

void main() {

int i;

scanf(“%d”,&i);

printf(“%d\n”,i);

}

the line scanf(“%d”,&i) reads an integer from the keyboard and store it in i

The line printf(“%d\n”,i) prints the value of i as integer followed by a new line

By now, you should have received feedback on the lab. There are 6 testcases, 0-3 and 4-5. If your program passed any of them, then the program is perfect (it can not pass all the cases by design). The difference between these two sets are in the left/right justified of the answer.

Her are the cases to check your code yourself.

The input files

00_input.txt 01_input.txt 02_input.txt 03_input.txt 04_input.txt 05_input.txt

The corresponding output

00_output.txt 01_output.txt 02_output.txt 03_output.txt 04_output.txt 05_output.txt

Example solution her is an example of countpos.c This is one way to implement it, there are many other ways to do the same thing.

LAB 2

Here is lab 2

Here are some example of inputs and output. There is no sense in submitting your code it it does not meet these two tests. use diff to be sure that your code is correct

test case 1 output sample 1

test case 2 output sample 2

Here are the rest of the test cases used in marking the lab

01_in.txt 02_in.txt 03_in.txt 04_in.txt

The corresponding outputs

01_out.txt 02_out.txt 03_out.txt 04_out.txt

Your program should read from the standard input, and display on the standard output. If you are doing this interactively (not using redirection), then the lines of the input and output will be interleaving. You type in the first line, when you hit return, the first line of output is displayed and so on. The end of file (Ctl-D) that is the end of input and the last 2 lines are displayed.

LAB 3

Here is lab_3.pdf

here is an input sample 00_in.txt and sample output lab3_00_out.txt (corrected)

and another sample l3_01_in.txt and the corresponding output l3_01_out.txt

The rest of the test cases

l3_02_in.txt l3_03_in.txt l3_04_in.txt l3_05_in.txt

The corresponding output files are

l3_02_out.txt l3_03_out.txt l3_05_in.txt lab3_00_out.txt

LAB 4

Here is Lab 4

In this lab, the output format is simple. You have to prepare test cases yourself. prepare a small file with the allowed words, one word per line, and test your input.

Her is a samplePractice problems (correcrted) . the first 2 questions are easy (15-20 min each). Question 3 is a bit difficult (1-2 hours). Question 4 is tricky. However, if you approach question 3 the right way, question 4 is not that difficult.

*Correction in lab4 practice questions problem 3. istead of x-by-11 matrix it should be x-by-22*

Here

is the dictionary I will be using for testing

you must open it as “../../dictionary.txt”

LAB 5

Here is lab_5.pdf

This lab is due Monday March February 22. I will post soon some test cases.

The overlap must be on the boundary

there are 3 cases are

case (1)

If the 2 inputs are

cde

abcdefgh

    the result is abcdefgh

case (2)

abcdefgh

efghzxcv

The resukt is  abcdefghzxcv

case (3)

efgh1234

abcdefgh

 The results is  abcdefgh1234 

The Your code should NOT display “The result is” just the length of the overlap and the string Also, the merged string should end with a new line (check modification to the lab).

here are some test cases for L5B (L5A is a subset of that)

l5_00_in.txt l5_00_out.txt

l5_02_in.txt l5_02_out.txt

l5_04_in.txt l5_04_out.txt

LAB 6

lab_6.pdf

Here are 2 files to test your code input and output

practice problems for lab 6 here

Please do not declare an array with variable size. There are two problems with that

  • It is not standard C
  • It allocate memory on the stack. For large memory allocation, it is better to do it on the heap (use malloc or any other such a function).

For this lab, you may assume a maximum size of 30×30 array

LAB 7

Lab 7 here. No submission for this lab, you have to do it in the lab

Lab 8

Lab 8

due Midnight Sunday march 20

an example of a simple shell script s11_sh.txt

the mycal program we discussed in the class mycal

Here are some examples, 3 data files and a script of a session running the code

ex1.txt ex2.txt ex3.txt

the script is here session.txt

Test cases

You have already received a copy of your labtest code, here are the test cases http://www.cse.yorku.ca/~aboelaze/testcases.html

LAB 9

lab_9.pdf is due last day of classes (includes problem 2)

Some extra exercise_problems.pdf

labs.1459269991.txt.gz · Last modified: 2016/03/29 16:46 by aboelaze

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki