1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <cstring>
using namespace std;
const int size = 200;
const int c = 200, r = 6;
string str[size];
int score[c][r];
int begin, end;
void value(int[][r], const int, const int);
void displayt(int [][r], int, int);
string genrandom();
void placestring();
void prompt(int&, int&);
void displayn(int&, int&);
void indepth(int&, int&);
int main()
{
char choice;
do
{
value(score, c, r);
genrandom();
placestring();
displayt(score, c, r);
prompt(begin, end);
displayn(begin, end);
indepth(begin, end);
cout << "\nExit: <y or no> _ ";
cin >> choice;
}
while(choice != 'y');
return 0;
}
void indepth(int &b, int &e)
{
string name;
cout << "\nEnter name to see position: ";
cin >> name;
for (int i = b; i < (e+1); i++)
{
if(name == str[i])
{
cout << "Position: " << i;
break;
}
}
cout << "\nNot Found..";
}
void displayn(int &b, int &e)
{
for(int i = b; i < (e+1); i++)
{
cout << endl;
cout << i << ". ";
cout << str[i];
}
}
void prompt(int &b, int &e)
{
cout << "\nData Entry <> _ ";
cin >> b >> e;
}
void value(int score [][r], const int column, const int row)
{
for(int i = 0; i < column; i++)
{
for(int j = 0; j < row; j++)
{
score[i][j] = 0 + rand() % 101;
}
}
}
string genrandom()
{
int L = 4 + rand() % 4;
string strung = " ";
for(int i = 0; i < L; i++)
{
strung[i] = 'a' + rand() % 26;
}
return strung;
}
void placestring()
{
for(int i = 0; i < size; i++)
{
str[i] = genrandom();
}
}
void displayt(int x[][r], const int column, const int row)
{
for(int i = 0; i < column; i++)
{
cout << i << ". ";
cout << str[i] << "\t\t";
for(int j = 0; j < row; j++)
{
cout << x[i][j] << "\t";
if(j == (row-1))
{
cout << endl;
}
}
}
}
|