Dev - C++ - menu c++

 
Vista:

menu c++

Publicado por Luis Fernando Morales Rosario (1 intervención) el 09/08/2019 01:24:36
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <vector>
#include <iostream>
 
 
using namespace std;
 
 
 
char alfabeto [27]={"A","B","C","D","E","F","G","H","I","J","K","L","N","M","Ñ","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
string cifrado(vector<char>msj,int b);
string desifrado (char msj[],int b, int tam);
int modulo(int a , int n);
vector<char> ctexto();
 
int main(int argc, char* argv) {
	//cout<<cifrado(26)<<endl;
 
	cout<<cifrado(ctexto(),0);
}
 
int modulo(int a , int n ) {
	{
	int m=0 , d=0;
	if(a>n){
		d=a/n;
		m=a-(d*n);
 
	}else{
		if(a<n){
			m=a;
		}
		else{
			if(a==n){
				m=a-n;
			}else{
				m=a+n;
			}
		}
	}
	return m;
 
	}
	}
 
string cifrado(vector<char>msj , int b){
	string cifra="";
	int pos=0;
	for(int i=0;i<sizeof(msj);i++){
		for(int j=0;j<27;j++){
			if(msj[i]==alfabeto[j]){
				pos=j+b;
				pos=modulo(pos,27);
				cifra+=alfabeto[pos];
			}
		}
	}
	return cifra;
}
string desifrado(char msj[],int b){
	string MD=""; int s;
	for(int i=0; i<27; i++){
		for(int j=0; j<27;j++){
			if(msj[i]==alfabeto[j]){
			s=j-b;
			s=modulo(s,27);
		    MD = alfabeto[s];
 
 
			}
		}
	}
	return  MD;
}
 vector<char> ctexto(string msj) {
 	int t; string txt;
 	cout<<"ingres el texto que va cifrar o desifrar"<<endl;
 	cin>>txt;
 	vector<char>v(txt.length());
 	copy(txt.begin(), txt.end(),v.begin());
    return v;
 	for(int j=0;j<v.size();j++){
 		cout<<v[j];
	 }
 }
void menu(){
    int op=0,clave=0;
    do{
 
switch(op){
    case 1:
    cout<<cifrado(ctexto("ingrese el a cifrar"),clave);
    break;
    case 2:
    cout<<cifrado(ctexto(),clave)
    break;
    case 3:
    cout<<"cerrado el programa";
     default:
    break;
    cout<<"opcion no valida";
}
 
}while(op<0);
  return ;
}



que error tiene
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder