1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Marat540 [252]
3 years ago
7

C++ Proagram

Computers and Technology
1 answer:
lions [1.4K]3 years ago
5 0

Answer:

Replace /* Your solution goes here */

with

for (i = 0; i < SCORES_SIZE-1; ++i) {

bonusScores[i] += bonusScores[i+1];

}

Explanation:

In C++, the index of an array starts from 0 and ends at 1 less than the size of the array;

Using the analysis in the question, the above code (in the answer section) iterates from the index element (element at 0) to the second to the last element (element at size - 2)';

This is to ensure that the element of the array only adds itself and the next element;except for the last index which remains unchanged

The following operation is done in each iteration.

When i = 0,

<em>bonusScores[0] = bonusScores[0] + bonusScores[0+1]; </em>

<em>bonusScores[0] = bonusScores[0] + bonusScores[1]; </em>

<em>bonusScores[0] = 10 + 20</em>

<em>bonusScores[0] = 30</em>

When i = 1,

<em>bonusScores[1] = bonusScores[1] + bonusScores[1+1]; </em>

<em>bonusScores[1] = bonusScores[1] + bonusScores[2]; </em>

<em>bonusScores[1] = 20 + 30</em>

<em>bonusScores[1] = 50</em>

<em />

When i = 2,

<em>bonusScores[2] = bonusScores[2] + bonusScores[2+1]; </em>

<em>bonusScores[2] = bonusScores[2] + bonusScores[3]; </em>

<em>bonusScores[2] = 30 + 40</em>

<em>bonusScores[2] = 70</em>

<em />

<em>This is where the iteration stops</em>

You might be interested in
If you have related data stored in multiple tables, create a(n) ________ to produce a pivottable on the combined data.
vladimir1956 [14]
If you have related data stored in multiple tables, create a Data model to<span> produce a pivot table on the combined data.
In computer term, data model refers to how each data are connected to one another and how those connections are being processed within the Sysyem</span>
3 0
4 years ago
Okay so remember that page I was advertising? At: fol ? Now it's deleted. And idk why because I was doing everything the right w
dimulka [17.4K]

Answer:

i don't think u can

Explanation:

maybe right a complaint or something

8 0
4 years ago
Jill edited James's document using Track Changes. James agrees with all of the edits and wants to incorporate them into his text
jenyasd209 [6]
The quick way for James to do so would be : A. open the tools menu, select options, and then select the track changes

with this method, James doesn't have to accept the edits one at a time which will waste his time

hope this helps
4 0
4 years ago
Implement the RC4 stream cipher in C++. User should be able to enter any key that is 5 bytes to 32 bytes long. Be sure to discar
gladu [14]

Answer:

Explanation:

#include <iostream>

#include <string>

#include<vector>

using namespace std;  

vector<int> permute(vector<int>, vector<int>);

string encrypt(vector<int>s1 , vector<int> t1, string p);

string decrypt(vector<int>s1, vector<int> t1, string p);

int main() {

  string plaintext = "cryptology";

  string plaintext2 = "RC4";

  vector<int> S(256);

  vector<int> T(256);

  int key[] = { 1,2,3,6 };

  int key2[] = { 5,7,8,9 };

  int tmp = 0;

  for (int i = 0; i < 256;i++) {

      S[i] = i;

      T[i] = key[( i % (sizeof(key)/sizeof(*key)) )];

  }

  S = permute(S, T);

  for (int i = 0; i < 256 ;i++) {

      cout << S[i] << " ";

      if ((i + 1) % 16 == 0)

          cout << endl;

  }

  cout << endl;

  string p = encrypt(S, T, plaintext);

  cout << "Message: " << plaintext << endl;

  cout << "Encrypted Message: " << " " << p << endl;

  cout << "Decrypted Message: " << decrypt(S, T, p) << endl << endl;

  tmp = 0;

  for (int i = 0; i < 256;i++) {

      S[i] = i;

      T[i] = key2[(i % (sizeof(key) / sizeof(*key)))];

  }

  S = permute(S, T);

  for (int i = 0; i < 256;i++) {

      cout << S[i] << " ";

      if ((i + 1) % 16 == 0)

          cout << endl;

  }  

  cout << endl;

  p = encrypt(S, T, plaintext2);

  cout << "Message: " << plaintext2 << endl;

  cout << "Encrypted Msg: " << p << endl;

  cout << "Decrypted Msg: "<<decrypt(S, T, p) << endl << endl;

  return 0;

}

string decrypt(vector<int>s1, vector<int> t1, string p) {

  int i = 0;

  int j = 0;

  int tmp = 0;

  int k = 0;

  int b;

  int c;

  int * plain = new int[p.length()];

  string plainT;

  for (int r = 0; r < p.length(); r++) {

      i = (i + 1) % 256;

      j = (j + s1[i]) % 256;

      b = s1[i];

      s1[i] = s1[j];

      s1[j] = b;

      tmp = (s1[i] + s1[j]) % 256;

      k = s1[tmp];

      c = ((int)p[r] ^ k);

      plain[r] = c;

      plainT += (char)plain[r];

  }

  return plainT;

}  

string encrypt(vector<int>s1, vector<int> t1, string p) {

  int i = 0;

  int j = 0;

  int tmp = 0;

  int k = 0;

  int b;

  int c;

  int * cipher = new int [p.length()];

  string cipherT;

  cout << "Keys Generated for plaintext: ";

  for (int r = 0; r < p.length(); r++) {

      i = (i + 1) % 256;

      j = (j + s1[i]) % 256;

      b = s1[i];

      s1[i] = s1[j];

      s1[j] = b;

      tmp = (s1[i] + s1[j]) % 256;

      k = s1[tmp];

      cout << k << " ";

      c = ((int)p[r] ^ k);

      cipher[r] = c;  

      cipherT += (char)cipher[r];

  }

  cout << endl;

  return cipherT;

}

vector<int> permute(vector<int> s1, vector<int> t1) {

  int j = 0;

  int tmp;

  for (int i = 0; i< 256; i++) {

      j = (j + s1[i] + t1[i]) % 256;

      tmp = s1[i];

      s1[i] = s1[j];

      s1[j] = tmp;

  }

  return s1;

}

6 0
3 years ago
You have just changed the system time within your computer's BIOS. You choose to save the settings upon exit. What happens next?
ozzi
When you were to choose the setting when exiting, the next step that would appear to happen would be the fact that the drive or the chip it's self would just stop. It would continue to work,but the main focus would be that it would not be functional.
4 0
3 years ago
Other questions:
  • When looking at an object or process to code, it is important to think of as general a solution as possible and consider all the
    13·1 answer
  • What is requirement analysis
    8·1 answer
  • The internet is a worldwide assembly of computer
    11·1 answer
  • "Most of us know that when we come into a college classroom, we will see desks and chairs, a computer station and a projector. A
    6·1 answer
  • Hey so if an instagram account has an email attached to it but a person no longer has access to that email, how do they get back
    10·1 answer
  • Developers and organizations all around the world leverage ______ extensively.
    9·2 answers
  • _____ selectors are used to select elements based on elements that are adjacent to them in the document hierarchy.
    9·1 answer
  • You are having difficulty changing permissions for a folder on an NTFS volume that was created by another user. How can you best
    6·1 answer
  • Six security issues and six descriptions are shown below.
    11·1 answer
  • in windows 10, what feature is used to locate and launch software or applications installed on your device?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!