[Solved] How would I make a simple encryption/decryption program? [closed]

Use two dicts to do the mapping, one from letters to encryption_code and the reverse to decrypt: letters=”ABCDEFGHIJKLMNOPQRSTUVWXYZ” encryption_code=”LFWOAYUISVKMNXPBDCRJTQEGHZ” enc = dict(zip(letters,encryption_code)) dec = dict(zip(encryption_code, letters)) s = “HELLO WORLD” encr = “”.join([enc.get(ch, ch) for ch in s]) decr = “”.join([dec.get(ch, ch) for ch in encr]) print(encr) print(decr) Output: IAMMP EPCMO HELLO WORLD Using your … Read more

[Solved] How to delete the book that have been input and how to make the title, language, and name doesn’t error if we put space on it? [closed]

If you want to enter data per line, here is an example: class Book { int number; int year; std::string language std::string name; std::string title; public: friend std::istream& operator>>(std::istream& input, Book& b); //… }; std::istream& operator>>(std::istream& input, Book& b) { std::string text_line; std::getline(input, text_line); std::istringstream text_stream(text_line); text_stream >> b.number >> b.year >> b.language >> b.name … Read more

[Solved] I dont understand error “definition of implicity-declared ‘Clothing::Clothing()’

The error is: you declared a destructor but you didn’t define it. Add a definition for the destructor or define it as default: #ifndef CLOTHING_H_ #define CLOTHING_H_ #include <string> #include <iostream> using namespace std; class Clothing { private: int gender; int size; string name; public: Clothing(); Clothing(const Clothing &t); Clothing(int gender, int size, string name); … Read more

[Solved] Extract part of log file

To get everything between two pattern you can use this sed command: sed -n ‘/.* id:.*/,/.* uid:.*/p’ log.txt And you’ll get — Request — some content …. — Response — …. where -n suppresses automatic printing of pattern space p prints the current pattern space 1 solved Extract part of log file

[Solved] How to chain and serialize functions by overloading the | operator

First I assume you have some basics that look like this #include <iostream> struct vec2 { double x; double y; }; std::ostream& operator<<(std::ostream& stream, vec2 v2) {return stream<<v2.x<<‘,'<<v2.y;} //real methods vec2 translate(vec2 in, double a) {return vec2{in.x+a, in.y+a};} //dummy placeholder implementations vec2 rotate(vec2 in, double a) {return vec2{in.x+1, in.y-1};} vec2 scale(vec2 in, double a) {return … Read more

[Solved] Long touch (touch and wait) on the cells in tableView

1) Add a UILongPressGestureRecognizer to you cell – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@”MyIdentifier”]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@”MyIdentifier”]; cell.selectionStyle = UITableViewCellSelectionStyleNone; //add longPressGestureRecognizer to your cell UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; //how long the press is for in seconds lpgr.minimumPressDuration = … Read more

[Solved] How to use System.out.format(); so that the answer can look like that? [closed]

You can get your expected out put using this code String[] B = {“2”, “14”, “5”, “12”, “10”}; String[] I = {“20”, “25”, “18”, “16”, “22”}; String[] N = {“42”, “32”, “FREE”, “31”, “39”}; String[] G = {“60”, “55”, “53”, “46”, “59”}; String[] O = {“64”, “70”, “67”, “75”, “71”}; String[][] test={B,I,N,G,O}; int n=0; System.out.println(“B … Read more

[Solved] Math Results Inaccurate PHP [closed]

In the line $open = fopen(“http://quote.yahoo.com/d/quotes.csv?s=$symbol&f=sl1d1t1c1ohgv&e=.csv”, “r”); You need to substitute the actual symbol, not leave it as a string in the query. Maybe something like this: $open = fopen(“http://quote.yahoo.com/d/quotes.csv?s=”.$symbol.”&f=sl1d1t1c1ohgv&e=.csv”, “r”); to concatenate the symbol will help. If you have an invalid request, you are probably looking at garbage. Also – you need to make … Read more

[Solved] How to loop back to the beginning of the code on Python 3.7

username = [‘admin’,’bill’,’Kevin’,’mike’,’nick’] while True : name =input(“Please enter a username: “) if name==’admin’ : print(“Hello “+ name + ” ,would you like to see a status report?”) break elif name in username : print(“Hello ” + name.title() + ” thank you for logging in!”) break else: print(“Who are you ” + name.title() + ” … Read more

[Solved] How do I send message programmatically in iPhone [closed]

Use following way : // Add delegate in .h file @interface ContactsViewController : UIViewController<MFMessageComposeViewControllerDelegate> // Add this in your .m file MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init]; if(picker) { picker.messageComposeDelegate = self; picker.recipients = [NSArray arrayWithObject:number]; picker.body = @”body content”; [self presentViewController:picker animated:NO completion:nil]; picker = nil; } NSLog(@”SMS fired”); – (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result { … Read more

[Solved] How to sort structs from least to greatest in C?

fix like this #include <stdio.h> #include <stdlib.h> #include <string.h> #define BUFF_SIZE 32 #define STRUCT_SIZE 512 struct info { char name[BUFF_SIZE]; char stAddress[BUFF_SIZE]; char cityAndState[BUFF_SIZE]; char zip[BUFF_SIZE]; }; void selectionSort(struct info *ptrStruct[], int size);//! int main(void){ int count, size;//! char buffer[600]; struct info *ptrStruct[STRUCT_SIZE]; for (count = 0; count < STRUCT_SIZE; count++){ ptrStruct[count] = (struct info*) … Read more