CS 176, Introduction to Computer Science II

Summer 2001 - Lab Test 3


A line in a file is perfect if it's the i-th line in the file and it contains i characters.

A line in a file is semi-perfect if the first character in the line is the i-th character in the file and the line contains i characters.

Write a program that reads the file my.dat and indicates which lines in the file are perfect and semi-perfect. The output of the program should look like

line 1 is perfect.
line 2 is perfect.
line 4 is semi-perfect.
Remember the following when writing your program:

You can find two test files txt.1 and txt.2 in

/export/home/us/csfac/cs176-summer2001/lt3
Perfect lines begin with p; semi-perfect lines begin with sp. You will have to rename the files to get them to work with your program.

Submit your test files using the command

/export/home/us/csfac/cs176-summer2001/bin/submit-lab-test your-files-here

where your-files-here are a list of the source files you've written for the test (your shell may let you abbreviate the command as ~csfac/cs176-summer2001/bin/submit-lab-test). You should get an e-mail response back in a few minutes. submit-lab-test is available from any linux system.

Make sure you submit something by the deadline. Unlike your programming assignments, you will not be able to submit you lab test after the 12:15 p.m. deadline.


This page last modified on 30 July 2001.