Sample codes... :)

Pages: 12
hi! i want to make a program that will input 5 student names and will input 4 grades for each student then will output the student name with the average of his/her grade using 2d array... this is what i've come up with so far...
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
#include<iostream>
#include<cstdlib>
using namespace std;

main()
{
      string studentgrade[5][4];
      string row, col;
      int r, c;
      
      for (r = 0; r < 5; r++)
      {
          cout << "enter name of student: " << r + 1 << endl;
          getline(cin,row);
          for (c = 0; c < 4; c++)
           {
             cout << "enter grade for student: " << r + 1 << endl;
             getline(cin,col);
           }
      cout<<studentgrade[row][col];
      }
      cout<<"\n\n";
      system("PAUSE");
      return 0;
}


it doesn't run... at all... i'm having a hard time making it... i'm new at this... please help! :(

this is the sample given to us by our instructor...

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
#include<iostream>

using namespace std;

main()
{
      string name[5];
      string term[4] = {"Prelim","Midterm","Semi-Final","Final"};
      string grade1[4];
      
      cout<<"Enter the name of the student:\n\n";
      
      for(int i=0;i<5;i++)
      { 
         cout<<"Enter the name of student "<<i+1<<" .) ";
         getline(cin,name[i]);        
      }
    
      cout<<"\n\nList of the students:\n";
      for(int i=0;i<5;i++)
      { 
         cout<<"\n\nEnter the name of student "<<i+1<<" .) "<<name[i];        
      }
       
      cout<<"\n\nEnter Grade for "<<name[0]<<"\n\n";
       
      for(int i=0;i<4;i++)
      {
           cout<<term[i]<<": ";cin>>grade1[i];     
      }
      
      cout<<"\n\nGrade for student named "<<name[0];
      for(int i=0;i<4;i++)
      {
           cout<<endl<<term[i]<<": "<<grade1[i];     
      }
      
      
      cout<<"\n\n";
      system("PAUSE");
      return 0;
}


it's not really complete...
Last edited on
closed account (Dy7SLyTq)
first you need #include <string>
second make a function that computes the average
ok here's the thing... i'm really new with c++... my programming 1 used java... and i took a break from school for 2 years... didn't really practice any of my programming skills... i don't know a lot of the commands used in c++... so i'm really having a hard time...
can you see the 2 lines on top? the ones starting with ( #include ), those are called include directives.
the cout word is an object defined in the "iostream" header, so if you want to use cout, you shall "include" the iostream header to be compiled into your program.
the same is with string, if you want to use it, you should include a header called string like this:

#include <string>

each directive must be on it's own line.
the includes must be outside the body of anything.
ok... but how do i make a program that will input a student's name then give that particular name it's grade for prelim, midterm, semi-finals and final... 5 students...

and the output will show the student's name and his average grade... using a 2d array...
i'm done! had some help with my classmates...

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
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;

main()
{
      string student[5];
      double grades[5][4];
      string term[4] = {"Prelim", "Midterm", "Semi-Final", "Final"};
      int i, row, col;
      double ave[5];
      
      for (i = 0; i < 5; i++)
      {
          cout << "Enter Name Of Student #" << i + 1 << ": ";
          getline(cin, student[i]);
      }

      for (row = 0; row < 5; row++)
      {
          cout << "Enter Grades for " << student[row] << ":" << endl << endl;
          for (col =0; col < 4; col++)
          {
              cout << term[col] << ": ";
              cin >> grades[row][col];
              ave[row] = ave[row] + grades[row][col]; 
          }
          cout << endl;
          ave[row] = ave[row]/4;
      }    
      
      for (row = 0; row < 5; row++)
      {
          cout << "Name of Student #" << row + 1 << " " << student[row] << endl;
          for (col = 0; col < 4; col++)
              {
                   cout << term[col] << ": " << grades[row][col] << endl;
              }
          cout << "\nWith an Average of " << ave[row] << endl << endl;
      }
      
      cout << endl;
      system("PAUSE");
      return 0;
}
updated version... :)

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
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;

main()
{
      string student[5];
      string term[4] = {"Prelim", "Midterm", "Semi-Final", "Final"};
      int grades[5][4], i, row, col;
      double ave[5], aveterm[4];
      
      for (i = 0; i < 5; i++)
      {
          cout << "Enter Name Of Student #" << i + 1 << ": ";
          getline(cin, student[i]);
          cout << endl;
      }

      for (row = 0; row < 5; row++)
      {
          cout << "Enter Grades for " << student[row] << ":" << endl << endl;
          for (col =0; col < 4; col++)
          {
              cout << term[col] << ": ";
              cin >> grades[row][col];
          }
          cout << endl;
      }
      for (row = 0; row < 5; row++)
      {
          for (col =0; col < 4; col++)
          {
              ave[row] = ave[row] + grades[row][col]; 
          }
          ave[row] = ave[row]/4;
      }
      for (col = 0; col < 4; col++)
      {
          for (row = 0; row < 5; row++)
          {
              aveterm[col] = aveterm[col] + grades[row][col];
          }
          aveterm[col] = aveterm[col]/5;
      }
      
      cout << " Student # | Student Name               |  P  ||  M  ||  S  ||  F  || Average" << endl;
      cout << "-----------------------------------------------------------------------------" << endl;
      for (row = 0; row < 5; row++)
      {
          cout << "     " << row + 1 << "     | " << student[row] << "\t\t";
          for (col = 0; col < 4; col++)
              {
                   cout << "|  " << grades[row][col] << "  |";
              }
          cout << "|    " << ave[row] << " ";
          cout << endl;
      }
      cout << "           | Average per Term\t\t";
      for (col = 0; col < 4; col++)
      {
          cout << "| " << aveterm[col] << " |";
      }    
      
      cout << "\n-----------------------------------------------------------------------------" << endl;
      cout << endl;
      system("PAUSE");
      return 0;
}
Last edited on
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
#include<iostream>
using namespace std;

main()
{
      int r,c,j=0,i=10,a[10][10];
      
      for(r=0;r<10;r++)
      {
       for (c=0;c<10;c++)
       {
        a[r][c]=0;
       }
      }
      
      for(r=0;r<10;r++)
      {
       for (c=0;c<10;c++)
       {
        cout<<a[r][c]<<" ";
       }
       cout<<endl;
      }
      
      cout<<endl;
      system("PAUSE");
      cout<<endl;
      
      for(r=j;r<10;r++)
      {
       for(c=j;c>0;c--)
       {
        cout<<"  ";
       }
       for(c=r;c<i;c++)
       {
        cout<<a[j][i]<<" ";
       }
       j++;
       i--;
       cout<<endl;
      }
      system("PAUSE");
      return 0;
}


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
#include<iostream>
using namespace std;

main()
{
      int r,c,j=0,i=10,a[10][10];
      
      for(r=0;r<10;r++)
      {
       for (c=0;c<10;c++)
       {
        a[r][c]=0;
       }
      }
      
      for(r=0;r<10;r++)
      {
       for (c=0;c<10;c++)
       {
        cout<<a[r][c]<<" ";
       }
       cout<<endl;
      }
      
      cout<<endl;
      system("PAUSE");
      cout<<endl;
      
      for(r=j;r<10;r++)
      {
       for(c=j;c<10;c++)
       {
        cout<<"  ";
       }
       for(c=r;c>i-2;c--)
       {
        cout<<a[j][i]<<" ";
       }
       j++;
       i--;
       cout<<endl;
      }
      
      cout<<endl;
      system("PAUSE");
      return 0;
}


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
#include <iostream>
using namespace std;

main ()
{
     int r, c, a[10][10];
     
     for (r=0;r<10;r++)
     {
      for(c=0;c<10;c++)
      {
       a[r][c]=0;
       }
     }
     for (r=0;r<5;r++)
     {
      for(c=0;c<=r;c++)
      {
       cout<<a[r][c]<< " ";
      }
      cout<<endl;
     }
     for (r=5;r>0;r--)
     {
      for(c=0;c<r;c++)
      {
       cout<<a[r][c]<< " ";
      }
      cout<<endl;
     }
     cout<<endl;
     system("PAUSE");
     return 0;
}

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
#include<iostream>
using namespace std;

main()
{
      int r,c,j=0,i=10,a[10][10];
      
      for(r=0;r<10;r++)
      {
       for (c=0;c<10;c++)
       {
        a[r][c]=0;
       }
      }
      
      for(r=0;r<10;r++)
      {
       for (c=0;c<10;c++)
       {
        cout<<a[r][c]<<" ";
       }
       cout<<endl;
      }
      
      cout<<endl;
      system("PAUSE");
      cout<<endl;
      
      for(r=10;r>4;r--)
      {
       for(c=i;c>0;c--)
       {
        cout<<"  ";
       }
       for(c=0;c<j;c++)
       {
        cout<<a[r][c]<<" ";
       }
       j++;
       i--;
       cout<<endl;
      }
      for(r=5;r>0;r--)
      {
       for(c=j-1;c>0;c--)
       {
        cout<<"  ";
       }
       for(c=i+1;c>0;c--)
       {
        cout<<a[r][c]<<" ";
       }
       j++;
       i--;
       cout<<endl;
      }
      system("PAUSE");
      return 0;
}

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
#include<iostream>
#include<string>
using namespace std;

main()
{
      int r,c;
      string a[10][10];
      
      for(r=0;r<10;r++)
      {
       for (c=0;c<10;c++)
       {
        a[r][c]="0";
       }
      }
      
      for(r=0;r<10;r++)
      {
       for (c=0;c<10;c++)
       {    
        if (r==c)
        cout<<"* ";
        else
        cout<<a[r][c]<<" ";
       }
       cout<<endl;
      }
      
      system("PAUSE");
      return 0;
}
Last edited on
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
#include<iostream>
using namespace std;

main()
{
      int r,c,j=0,i=10,l=0,m=10,a[10][10];
      
      for (r = 0; r < 10; r++)
      {
          for (c = 0; c < 10; c++)
          {
              a[r][c] = 0;
          }
      }
      
      for (r = 0; r < 10; r++)
      {
          for (c = 0; c < 10; c++)
          {
              cout << a[r][c] << " ";
          }
          cout << endl;
      }
      
      cout << "\n\n";
      
      for(r=j;r<10;r++)
      {
       for(c=j+1;c<10;c++)
       {
        cout<<"  ";
       }
       for(c=r;c>i-2;c--)
       {
        cout<<a[j][i]<<" ";
       }
       j++;
       i--;
       cout<<endl;
      }
      
      for(r=l;r<10;r++)
      {
       for(c=l;c>0;c--)
       {
        cout<<"  ";
       }
       for(c=r;c<m;c++)
       {
        cout<<a[l][m]<<" ";
       }
       l++;
       m--;
       cout<<endl;
      }
      
      cout << endl;
      system("PAUSE");
      return 0;
}
Last edited on
I would have thought to not try and use one 2d array because names would be a string and grades averages would be dealing with math.

these are not easily compatable. wouldn't it be easier to use structs and then put your structs into an array of structs, if needed?

something like...

1
2
3
4
5
6
7
struct student {
string first_name;
string last_name;
int grades[4];
int gradeAverage;
};


this would be my approach.

Last edited on
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
#include<iostream>
using namespace std;

main()
{
      int ***wee, l, w, d, i, j, k;
      
      cout<<"Enter side of wee\n";
      cout<<"l: ";
      cin>>l;
      cout<<"\nw: ";
      cin>>w;
      cout<<"\nd: ";
      cin>>d;
      
      wee=new int** [l];
      cout<<endl;
      
      for(i=0; i<l; i++)
      {
              for(j=0; j<w; j++)
              wee[i]=new int* [w];
      }
      
      for(i=0; i<l; i++)
      {
              for(j=0; j<w; j++)
              {
                      for(k=0; k<d; k++)
                      wee[i][j]=new int[d];
              }
      }
      
      for(i=0; i<l; i++)
      {
              for(j=0; j<w; j++)
              {
                      for(k=0; k<d; k++)
                      {
                              cout<<"Enter ["<<i<<"]"<<"["<<j<<"]"<<"["<<k<<"]: ";
                              cin>>wee[i][j][k];
                              cout<<endl;
                      }
              }
      }
      
      for(i=0; i<l; i++)
      {
              for(j=0; j<w; j++)
              {
                      for(k=0; k<d; k++)
                      {
                              cout<<wee[i][j][k]<<" ";
                      }cout<<endl;
              }cout<<endl<<endl;
      }
      
      cout<<wee[0][0][0]<<endl;
      
      for(i=0; i<l; i++)
      {
              for(j=0; j<w; j++)
              {
                      for(k=0; k<d; k++)
                      delete [] wee[i][j];
              }
      }
      
      for(i=0; i<l; i++)
      {
              for(j=0; j<w; j++)
              delete [] wee[i];
      }
      
      delete wee;
      
      cout<<wee[0][0][0]<<endl;
      
      cout<<endl;
      system("PAUSE");
      return 0;
}
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
118
119
120
121
122
123
124
125
126
127
#include<iostream>
using namespace std;

int n;

struct b
{
       string m;
       string d;
       string y;
};

struct p
{
       string fn;
       string mn;
       string ln;
       string g;
       int a;
       double h;
       float w;
       b bd;
};

main()
{
      int i, j, h;
      cout<<"Enter number of students: ";
      cin>>n;
	
      p *s;
	
      s = new p [n]; 
	
      for(i=0; i<n; i++)
      {
        cout<<"\n\n";
        cout<<"Enter the first name of #"<<i+1<<" student: ";
		cin>>s[i].fn;
		cout<<"Enter the middle name of "<<s[i].fn<<": ";
		cin>>s[i].mn;
        cout<<"Enter the last name of "<<s[i].fn<<": ";
		cin>>s[i].ln;
		cout<<"Enter the age of "<<s[i].fn<<" "<<s[i].mn<<" "<<s[i].ln<<": ";
		cin>>s[i].a;
		cout<<"Enter the gender of "<<s[i].fn<<" "<<s[i].mn<<" "<<s[i].ln<<": ";
		cin>>s[i].g;
		cout<<"Enter the birthday of "<<s[i].fn<<" "<<s[i].mn<<" "<<s[i].ln<<"\nMonth: ";
		cin>>s[i].bd.m;
		cout<<"Day: ";
		cin>>s[i].bd.d;
		cout<<"Year: ";
        cin>>s[i].bd.y;
        cout<<"Enter the weight of "<<s[i].fn<<" "<<s[i].mn<<" "<<s[i].ln<<": ";
        cin>>s[i].w;
        cout<<"Enter the height of "<<s[i].fn<<" "<<s[i].mn<<" "<<s[i].ln<<": ";
        cin>>s[i].h;
      }
      
      for(j=n-1; j>0; j--)
      {
            for(h=0; h<j; h++)
            {
                   if(s[h].ln>s[h+1].ln)
                   {
                          string t = s[h].fn;
                          s[h].fn = s[h+1].fn;
                          s[h+1].fn = t;
                          
                          string t2 = s[h].mn;
                          s[h].mn = s[h+1].mn;
                          s[h+1].mn = t2;
                          
                          string t3 = s[h].ln;
                          s[h].ln = s[h+1].ln;
                          s[h+1].ln = t3;
                          
                          int t4 = s[h].a;
                          s[h].a = s[h+1].a;
                          s[h+1].a = t4;
                          
                          string t5 = s[h].g;
                          s[h].g = s[h+1].g;
                          s[h+1].g = t5;
                          
                          string t6 = s[h].bd.m;
                          s[h].bd.m = s[h+1].bd.m;
                          s[h+1].bd.m = t6;
                          
                          string t7 = s[h].bd.d;
                          s[h].bd.d = s[h+1].bd.d;
                          s[h+1].bd.d = t7;
                          
                          string t8 = s[h].bd.y;
                          s[h].bd.y = s[h+1].bd.y;
                          s[h+1].bd.y = t8;
                          
                          float t9 = s[h].w;
                          s[h].w = s[h+1].w;
                          s[h+1].w = t9;
                          
                          double t10 = s[h].h;
                          s[h].h = s[h+1].h;
                          s[h+1].h = t10;
                   }
            }
      }
      
      cout<<"\n\n";
      
      for(i=0; i<n; i++)
	  {
		cout<<"Full Name:"<<s[i].ln<<", "<<s[i].fn<<" "<<s[i].mn;
		cout<<"\nAge: "<<s[i].a;
		cout<<"\nGender: "<<s[i].g;
		cout<<"\nBirthday: "<<s[i].bd.m<<" "<<s[i].bd.d<<", "<<s[i].bd.y;
		cout<<"\nWeight: "<<s[i].w;
		cout<<"\nHeight: "<<s[i].h;
		cout<<"\n\n";
	  }
	  
	  delete s;
      
      cout<<"\n\n";
      system("PAUSE");
      return 0;
}
Last edited on
closed account (28poGNh0)
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
# include <iostream>
using namespace std;

struct student
{
    string fullName;
    int mathGrade;
    int physicsGrade;
    int historyGrade;
    int cookingGrade;
};

int main()
{
    student st[5];

    cout << "Load students info" << endl << endl;
    for(int i=0;i<5;i++)
    {
        cout << "==============" << endl;
        cout << "Student nbr " << i+1 << endl;
        cout << "==============" << endl;

        cout << "Enter the whole name -> ";getline(cin,st[i].fullName);
        cout << "Enter math grade     -> ";cin >> st[i].mathGrade;
        cout << "Enter physics grade  -> ";cin >> st[i].physicsGrade;
        cout << "Enter history grade  -> ";cin >> st[i].historyGrade;
        cout << "Enter cooking grade  -> ";cin >> st[i].cookingGrade;
        cout << endl;
        cin.ignore();
    }

    cout << endl;
    
    // if you want to show all of students info

    cout << "Display students info" << endl << endl;
    for(int i=0;i<5;i++)
    {
        cout << "==============" << endl;
        cout << "Student nbr " << i+1 << endl;
        cout << "==============" << endl;

        cout << "Enter the whole name -> " << st[i].fullName << endl;
        cout << "Enter math grade     -> " << st[i].mathGrade << endl;
        cout << "Enter physics grade  -> " << st[i].physicsGrade << endl;
        cout << "Enter history grade  -> " << st[i].historyGrade << endl;
        cout << "Enter cooking grade  -> " << st[i].cookingGrade << endl << endl;
    }

    return 0;
}


I hope that helps
Last edited on
manga and techno1... thanks... it really did help... it made the program simpler and a lot easier to manipulate the data... :)
closed account (28poGNh0)
You're welcome dont forget to mark it as solved(It realy helps this community!)
if i "mark it as solved"... will i still be able to post here?...
closed account (Dy7SLyTq)
yeah
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
#include<iostream>
using namespace std;

struct s{
       int x;
       int y;
       
       int add(int a, int b)
         {
         int r;
         r=a+b;
         return (r);
         };
       int sub(int a, int b)
         {
         int r;
         r=a-b;
         return (r);
         };
       double mul(double a, double b)
         {
         double r;
         r=a*b;
         return (r);
         };
       float div(float a, float b)
         {
         float r;
         r=a/b;
         return (r);
         };
       };     
       
main()
{
      s op;
      cout<<"enter value for x: ";
      cin>>op.x;
      cout<<"enter value for y: ";
      cin>>op.y;
      cout<<"\n\n";
      cout<<"\nAddition: "<<op.add(op.x,op.y);
      cout<<"\nSubtraction: "<<op.sub(op.x,op.y);
      cout<<"\nMultiplication: "<<op.mul(op.x,op.y);
      cout<<"\nDivision: "<<op.div(op.x,op.y);

      cout<<"\n\n";
      system("PAUSE");
      return 0;
}
Last edited on
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#include<iostream>
#include<string>
#include<fstream>
using namespace std;

string en(string x)
{
      for(int i=0;i<x.size();i++)
      ++x[i];
      
      for(int i=0;i<=x.size();i++)
      {
              if(x[i]=='a')
              x[i]='q';
              else if(x[i]=='b')
              x[i]='w';
              else if(x[i]=='c')
              x[i]='e';
              else if(x[i]=='d')
              x[i]='r';
              else if(x[i]=='e')
              x[i]='t';
              else if(x[i]=='f')
              x[i]='y';
              else if(x[i]=='g')
              x[i]='u';
              else if(x[i]=='h')
              x[i]='i';
              else if(x[i]=='i')
              x[i]='o';
              else if(x[i]=='j')
              x[i]='p';
              else if(x[i]=='k')
              x[i]='a';
              else if(x[i]=='l')
              x[i]='s';
              else if(x[i]=='m')
              x[i]='d';
              else if(x[i]=='n')
              x[i]='f';
              else if(x[i]=='o')
              x[i]='g';
              else if(x[i]=='p')
              x[i]='h';
              else if(x[i]=='q')
              x[i]='j';
              else if(x[i]=='r')
              x[i]='k';
              else if(x[i]=='s')
              x[i]='l';
              else if(x[i]=='t')
              x[i]='z';
              else if(x[i]=='u')
              x[i]='x';
              else if(x[i]=='v')
              x[i]='c';
              else if(x[i]=='w')
              x[i]='v';
              else if(x[i]=='x')
              x[i]='b';
              else if(x[i]=='y')
              x[i]='n';
              else if(x[i]=='z')
              x[i]='m';
              else if(x[i]=='A')
              x[i]='M';
              else if(x[i]=='B')
              x[i]='N';
              else if(x[i]=='C')
              x[i]='B';
              else if(x[i]=='D')
              x[i]='V';
              else if(x[i]=='E')
              x[i]='C';
              else if(x[i]=='F')
              x[i]='X';
              else if(x[i]=='G')
              x[i]='Z';
              else if(x[i]=='H')
              x[i]='A';
              else if(x[i]=='I')
              x[i]='S';
              else if(x[i]=='J')
              x[i]='D';
              else if(x[i]=='K')
              x[i]='F';
              else if(x[i]=='L')
              x[i]='G';
              else if(x[i]=='M')
              x[i]='H';
              else if(x[i]=='N')
              x[i]='J';
              else if(x[i]=='O')
              x[i]='K';
              else if(x[i]=='P')
              x[i]='L';
              else if(x[i]=='Q')
              x[i]='P';
              else if(x[i]=='R')
              x[i]='O';
              else if(x[i]=='S')
              x[i]='I';
              else if(x[i]=='T')
              x[i]='U';
              else if(x[i]=='U')
              x[i]='Y';
              else if(x[i]=='V')
              x[i]='T';
              else if(x[i]=='W')
              x[i]='R';
              else if(x[i]=='X')
              x[i]='E';
              else if(x[i]=='Y')
              x[i]='W';
              else if(x[i]=='Z')
              x[i]='Q';
              else if(x[i]=='0')
              x[i]='9';
              else if(x[i]=='1')
              x[i]='8';
              else if(x[i]=='2')
              x[i]='7';
              else if(x[i]=='3')
              x[i]='6';
              else if(x[i]=='4')
              x[i]='5';
              else if(x[i]=='5')
              x[i]='4';
              else if(x[i]=='6')
              x[i]='3';
              else if(x[i]=='7')
              x[i]='2';
              else if(x[i]=='8')
              x[i]='1';
              else if(x[i]=='9')
              x[i]='0';
              else if(x[i]=='.')
              x[i]='=';
              else if(x[i]==',')
              x[i]='`';
              else if(x[i]==' ')
              x[i]=']';
              else if(x[i]=='!')
              x[i]='[';
              else if(x[i]=='?')
              x[i]='-';
      }
      return x;
}

main()
{
      ofstream out;
      out.open("E:\\Dev-Cpp\\Codes\\output.txt");
      ifstream in;
      in.open("E:\\Dev-Cpp\\Codes\\in.txt", ios::in);
      int n=0;
      string a[10000];
      
      while (in.good())
      {
        getline(in,a[n]);
        n++;
      }     
      
      for(int i=0;i<n;i++)
      {
       en(a[i]);
      }
      
      for(int i=0;i<n;i++)
      {
       out<<en(a[i])<<endl;
      }
      
      in.close();
      out.close();
      system("pause");
      return 0;
}
Last edited on
closed account (Dy7SLyTq)
omfg... we must kill all necromancers kel' thuzad style. ill grab a hammer
Pages: 12