why is this wrong for vectors
vector<char> decrypt{
{'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5',
'6', '7', '8', '9', 'A'},
{'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'A', 'B'},
};
for(int i = 0; i < 2); i++)
{
for(int j = 0; j < 35; j++)
{
cout << decrypt[i]{j} << endl;
}
cout << endl << endl;
}
//error in declaration
//you didn't followed the declaration syntax for 2d
vector
//you initializing with 2d values to a 1d char
vector
//for example
/*vector<vector<int> > vect{ { 1, 2, 3
},
{ 4, 5, 6 },
{ 7, 8, 9 } }; *///is a 2d vector
vector<char> decrypt{
{'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5',
'6', '7', '8', '9', 'A'},
{'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'A', 'B'},//error here coma , is not required
heer
};
for(int i = 0; i < 2); i++)//error here ) is required
{
for(int j = 0; j < 35; j++)
{
cout << decrypt[i]{j} << endl;//error is here you have
to use decrypt[i][j] to access values
}
cout << endl << endl;
}
//correct working code
#include<iostream>
#include<vector>
using namespace std;
int main()
{
//corrected code
vector<vector<char> > decrypt{
{'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5',
'6', '7', '8', '9', 'A'},
{'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'A', 'B'}
};
for(int i = 0; i < 2; i++)
{
for(int j = 0; j < 35; j++)
{
cout << decrypt[i][j] << endl;
}
cout << endl << endl;
}
return 0;
}
//PLS give a thumbs up if you find this helpful, it helps me alot, thanks.
why is this wrong for vectors vector<char> decrypt{ {'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',...
12.22 Chapter 4: Encrypt Characters Simple Caesar Cipher challenge. You'll need to correct code to print ciphertext character correctly. With offset of 3 the output should be ORIGINAL CHARACTERS A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ENCRYPTED CHARACTERS D E F G H I J K L M N O P Q R S T U V W X Y Z...
Need help in c++ programming to output the lines in my code: if word if found: cout << "'" << word << "' was found in the grid" << endl; cout << "'" << word << "' was not found in the grid" << endl; The words can be touching if they are horizontally, vertically, or diagonally adjacent. For example, the board: Q W E R T A S D F G Z X C V B Y U A...
Spell it out! Use the following Java concepts to compile the program below: String myName = "Chuck"; int length = myName.length(); char firstChar = myName.charAt(0); char secondChar = myName.charAt(1); if (myName.equals("Tom")) { System.out.println ("Sorry, Tom!"); } Write a program that uses a METHOD to translate these individual characters: input output input output input output input output input output a 4 g 9 m /\\/\\ s $ y ‘/ b B h |-| n |\\| t...
please help with the operator overloading lab (intArray) in c++ will provide what it is being required and the code that was given from the book. the code that was provided is below ------------------------------------------------------------------------------------------------------------------------- // iadrv.h #ifndef _IADRV_H #define _IADRV_H #include "intarray.h" int main(); void test1(); void test2(); void test3(); void test4(); void test5(); void test6(); void test7(); void test8(); void test9(); void test10(); void test11(); void test12(); void test13(); void test14(); void test15(); void test16(); void test17(); void test18();...
I don't know how to terminate the code in the second time that whether or not the users want to continue to get a new number. PLEASE HELP. To make telephone numbers easier to remember, some companies use letters to show their telephone number. For example, using letters, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 225-5466 can be displayed...
#include #include #include #include #include #include #include using namespace std; const int MAX = 26; string addRandomString(int n) { char alphabet[MAX] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; string res = ""; for (int i = 0; i < n; i++) res = res + alphabet[rand() % MAX]; return res;...
Please explain the python code below L1 = [2, 15, 'Carol', 7.4, 0, -10, -6, 42, 27, -1, 2.0, 'hello', [2, 4], 23] print("L1 =",L1) odds =[] evens=[] list=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',',','.'] no=0 for i in L1: i=str(i) for j in list: if i.find(j)>=0: no=1 if no==1: None else: i=int(i) if i%2==0: evens.append(i) else: odds.append(i) no=0 ...
- A. B. C. D. E. F. G. H. I. J. K. L. M. N. O. Telecommuting - A. B. C. D. E. F. G. H. I. J. K. L. M. N. O. Change - A. B. C. D. E. F. G. H. I. J. K. L. M. N. O. Job Sharing - A. B. C. D. E. F. G. H. I. J. K. L. M. N. O. Job Redesign - A. B. C. D. E. F. G. H. I. ...
the two codes have an error and I can’t figure out where. First one public class Program { public static void main(String[] args) { int i, j = 1, k = 0; String alphabet = "abcdefghijklmnopqrstuvwxyz"; i = alphabet.length(); while (i>0){ j=(i-(i-j)); System.ou.println(alphabet.charAt(k)+" is the number "+j"letter in the alphabet"); k++; j++; i--; } } } Second one char [] alphabet = {a,b,c,d,e,f,g,h,I,j,k,l,m,n,o,p,a,r,s,t,u,v,w,x,y,z}; for (int i = 0; i < alphabet.length; i++) { System.out.println(alphabet[i] +...
def average_word_length(string): num_words = 0 if not type(string)==str: return "Not a string" if not "A" or not "B" or not "C" or not "D" or not "E" or not "F" or not "G" or not "H" or not "I" or not "J"\ or not "K" or not "L" or not "M" or not "N" or not "O" or not "P" or not "Q" or not "R" or not "S" or not "T"\ or not "U" or not "V" or not...