Public feed #892208

Anonymous

public text v1 · immutable
Raw Edit
·published 2008-02-05 05:59 UTC
rendered paste body
// Ryans Homework.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

//Ryan Weber Program 0
# include <iostream>
#include <fstream>
using namespace std;
using std::ofstream;

int counter=0;
char ch;
int lnct=0;
int chct=0;
const int DefaultListSize=100;
typedef char Elem;
class Astack
{
	private:
		int size;
        int top;
        Elem *listArray;
    public:
		Astack(int sz =DefaultListSize)
		{
            size=sz;
            top=0;
            listArray=new Elem[sz];
         }
         ~Astack() {delete [] listArray;}
         void clear() {top=0;}
         bool push(const Elem& item)
         {
			 if (top == size) return false;
             else { listArray[top++] = item; return true;}
         }
         bool pop(Elem& it)
         {
			if (top==0) return false;
            else{  it=listArray[--top]; return true; }
         }
         bool topValue(Elem& it) const
         {
			 if (top == 0) return false;
             else { it = listArray[top-1]; return true;}
         }
         int length() const {return top;}
         bool IsEmpty() const {return (top==0);}
};
                  
int main()
{
	while((ch=cin.get())!=EOF)
    {
		if (ch!='\n')
        {
			chct++;
            cout<< ch << " ";
            cout<<"The number of characters is: " << chct << endl;
		}
		else
		{
			lnct++;
            cout<<endl;
            cout<<"The number of lines is: " << lnct << endl;
		}
                //cout<<"The number of characters is: " << chct << endl;
                //cout<<"The number of lines is: " << lnct << endl;
                         
	}
        cout<<"Programmer: Ryan Weber \n  Class: CS 258\n\n";
        return 0;
}  //end main