Password Encryption Problems

Source: Internet
Author: User

Tag: Move

Password Encryption Problems

Personal information: He is a junior majoring in software engineering at yanda University;

My blog: Google searches for "cqs_2012;

My hobbies: I love data structures and algorithms and hope to make my own contribution to algorithm work in the future;

Programming Language: C ++;

Programming Environment: Windows 7 Professional Edition x64;

Programming tools: vs2010;

Drawing tools: Office 2010 PowerPoint;

Hardware information: 7g-3 Notebook;


If you have not completed the task, it is not a task problem, it is your own problem.


Best Practice 2818


1. Violence Law, calculated once, moved once

2 optimization: computing is performed once, tracking is performed once, re-computing is performed, tracking is performed, and finally moving is performed.

3 optimization: calculate the number of times to move, calculate the final result, and then move

AC code

#include <iostream>#include <string>#include <vector>using namespace std;bool my_2818(vector<string> * myvector);int main(){bool sum = true;vector<string> * myvector = new vector<string>;vector<string>::iterator it;while(sum == true)sum = my_2818( myvector );it = myvector->begin();while(it < myvector->end()){cout<<*it<<endl;it++;}system("pause");return 0;}bool my_2818(vector<string> * myvector){int n;cin>>n;if(n == 0){return false;}int * data = new int[n];int *length = new int[n];for(int i=0;i<n;i++){cin>>data[i];length[i] = 0;}for(int j,i=0;i<n;i++){j = data[i]-1;length[i]++;while(true){if(j == i)break;j = data[j]-1;length[i]++;}}int k;string a;char* b = new char[n];char c;while(true){cin>>k;if(k == 0)break;for(int i=0;i<n;i++){b[i] = ' ';}getline(cin,a,'\n');a=a.substr(1,a.length()-1);while(a.length()<n)a+=' ';for(int i=0;i<n;i++){int j = k % length[i];int m = i;while(j>0){m = data[m]-1;j--;}b[m] = a[i];}string result="";for(int j=0;j < n;j++)result+=b[j];myvector->push_back(result);}myvector->push_back("");return true;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.