home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 14 Text
/
14-Text.zip
/
results.zip
/
count.cpp
next >
Wrap
C/C++ Source or Header
|
1994-05-23
|
3KB
|
96 lines
/* x.cpp */
#include <stream.h>
#include <string.h>
enum { MAJOR, AGREE, INDIFFERENT, OPPOSED, TOTAL };
int main( void)
{
int Major;
int Minor;
int Vote;
int Matrix[ 99][ 55][ 5];
ifstream File( "parsedvote");
memset( Matrix, 0, sizeof( Matrix));
while ( 1) {
File >> Major >> Minor >> Vote;
if ( ! File.good()) {
break;
}
++ Matrix[ Major][ Minor][ Vote];
++ Matrix[ Major][ Minor][ TOTAL];
}
cout.fill( ' ');
cout.setf( ios::left);
cout << setw( 6) << "Item";
cout.unsetf( ios::left);
cout << setw( 10) << "YES!";
cout << setw( 10) << "Agree";
cout << setw( 10) << "Indif";
cout << setw( 10) << "Opposed" << endl;
cout.unsetf( ios::right);
for ( Major = 1; Major < 99; ++ Major) {
for ( Minor = 1; Minor < 55; ++ Minor) {
if ( Matrix[ Major][ Minor][ TOTAL] != 0) {
cout.setf( ios::right);
cout << setw( 2) << Major << '.';
cout.unsetf( ios::right);
cout.setf( ios::left);
cout << setw( 3) << Minor;
cout.unsetf( ios::left);
cout.setf( ios::right);
cout << setw( 10) << Matrix[ Major][ Minor][MAJOR];
cout << setw( 10) << Matrix[ Major][ Minor][AGREE];
cout << setw( 10) << Matrix[ Major][ Minor][INDIFFERENT];
cout << setw( 10) << Matrix[ Major][ Minor][OPPOSED];
cout << setw( 10) << Matrix[ Major][ Minor][TOTAL] << endl;
cout.unsetf( ios::right);
}
}
}
cout.fill( ' ');
cout.setf( ios::left);
cout << "\n\nPercentages\n\n";
cout << setw( 6) << "Item";
cout.unsetf( ios::left);
cout << setw( 10) << "YES!";
cout << setw( 10) << "Agree";
cout << setw( 10) << "Indif";
cout << setw( 10) << "Opposed" << endl;
cout.unsetf( ios::right);
cout.setf( ios::fixed);
for ( Major = 1; Major < 99; ++ Major) {
for ( Minor = 1; Minor < 55; ++ Minor) {
if ( Matrix[ Major][ Minor][ TOTAL] != 0) {
cout.setf( ios::right);
cout << setw( 2) << Major << '.';
cout.unsetf( ios::right);
cout.setf( ios::left);
cout << setw( 3) << Minor;
cout.unsetf( ios::left);
cout.setf( ios::right);
cout << setw( 10) << setprecision( 2) << (float) Matrix[ Major][ Minor][MAJOR] / Matrix[ Major][ Minor][ TOTAL] * 100;
cout << setw( 10) << setprecision( 2) << (float) Matrix[ Major][ Minor][AGREE] / Matrix[ Major][ Minor][ TOTAL] * 100;
cout << setw( 10) << setprecision( 2) << (float) Matrix[ Major][ Minor][INDIFFERENT] / Matrix[ Major][ Minor][ TOTAL] * 100;
cout << setw( 10) << setprecision( 2) << (float) Matrix[ Major][ Minor][OPPOSED] / Matrix[ Major][ Minor][ TOTAL] * 100 << endl;
cout.unsetf( ios::right);
}
}
}
}