Not logged in. Log in with GitHub. About Websheets.

List of all available Websheets


Viewing cpp/cstrings/cipher by redekopp@usc.edu. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
PropertyValue
Description
html markup
shown to student
 
Lets create a cipher code to encrypt text
<tt>abcdefghijklmnopqrstuvwxyz</tt>=><br>
<tt>ghijklmaefnzyqbcdrstuopvwx</tt>
<p>
   So if the user enters <tt>helloworld</tt>, your output should be <tt>akzzbpbrzj</tt>
Engine
Template / Reference solution
 
#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, char *argv[])
{
  
  char my_string[\[ REDACTED ]\ ], new_string[\[ REDACTED ]\];
  // cipher index=>0123456789...            25
  char cipher[] = "ghijklmaefnzyqbcdrstuopvwx";
  cout << "Enter a text string of 80 or less lower case characters without spaces or punctuation:\n" << endl;
  // cin will stop string entry on the first whitespace (space, tab, newline, etc.)
  // cin.getline() can be used to get an entire line of text...Google 
  //   cin getline to find parameters and return values.
  cin >> my_string;
\[
REDACTED
]\
  cout << "Encrypted text string is...\n" << new_string << endl;
  return 0;
}
C++ test suite
json list of stdin/args tests
e.g. [{"stdin":"hi", "args":["4", "5"]},
{"stdin":"noargs"}]

to just run once with no input use [{}]
 
[ {"stdin":"helloworld" },
 {"stdin":"abc"},
 {"stdin":"abcdefghijklmnopqrtsuvwxyz"} ]


Optional properties:

Note: problems are open-source by default (see 'Public permissions'). Assumed license for open problems is Creative Commons 4.0 Attribution-ShareAlike unless specified in 'Remarks'.