vc hack
April 10th, 1999, 11:43 AM
Help me fiqure out??????
i was given a program to rewrite has problems in it........here is the code i was given to complete
should run alphbet Row 1: A-M Row 2: a-m Row 3:N-Z
Row 4: n-z while keeping trac of hit example A:01, B:25 so on etc here it code have to follow and tips will be appreciated
Thanks for your comments and help
#include <iostream>
using namespace std;
void main(void)
{
int counts[52];
int words = 0;
int characters = 0;
void init(int *);
int input(int *, int *);
void output(int *,int, int);
init(counts);
characters = input(counts, &words);
output(counts, characters, words);
}
int input(int * counts, int * words)
{
char ch;
int characters = 0;
int in_a_word = 0;
characters++;
while((ch = cin.get()) != EOF)
{
if(ch >= 'a' && ch <= 'z')
counts[ch - 'a']++;
else if (ch >= 'A' && ch <= 'Z')
counts[ch - 'A' + 26]++;
if (ch == ' ');
if (in_a_word == 1)
{
(*words)++;
in_a_word = 0;
}
else
in_a_word = 1;
if(ch!=' ')words++;
cout << characters;
}
return characters++;
}
void output(int * counts, int characters, int words)
{
for(int b = 0; b < 13; b++)
cout << 'A' + b << ':' << counts[b];
for(int a = 0; a < 13; a++)
cout << 'a' + a << ':' << counts[a];
for(int c = 14; c <= 26; c++)
cout << 'N' + b << ':' << counts[c];
for(int n = 14; n <= 26; n++)
cout << 'n' + n << ':' << counts[n];
}
void init(int * counts)
{
}
i was given a program to rewrite has problems in it........here is the code i was given to complete
should run alphbet Row 1: A-M Row 2: a-m Row 3:N-Z
Row 4: n-z while keeping trac of hit example A:01, B:25 so on etc here it code have to follow and tips will be appreciated
Thanks for your comments and help
#include <iostream>
using namespace std;
void main(void)
{
int counts[52];
int words = 0;
int characters = 0;
void init(int *);
int input(int *, int *);
void output(int *,int, int);
init(counts);
characters = input(counts, &words);
output(counts, characters, words);
}
int input(int * counts, int * words)
{
char ch;
int characters = 0;
int in_a_word = 0;
characters++;
while((ch = cin.get()) != EOF)
{
if(ch >= 'a' && ch <= 'z')
counts[ch - 'a']++;
else if (ch >= 'A' && ch <= 'Z')
counts[ch - 'A' + 26]++;
if (ch == ' ');
if (in_a_word == 1)
{
(*words)++;
in_a_word = 0;
}
else
in_a_word = 1;
if(ch!=' ')words++;
cout << characters;
}
return characters++;
}
void output(int * counts, int characters, int words)
{
for(int b = 0; b < 13; b++)
cout << 'A' + b << ':' << counts[b];
for(int a = 0; a < 13; a++)
cout << 'a' + a << ':' << counts[a];
for(int c = 14; c <= 26; c++)
cout << 'N' + b << ':' << counts[c];
for(int n = 14; n <= 26; n++)
cout << 'n' + n << ':' << counts[n];
}
void init(int * counts)
{
}