Dev - C++ - No sé por qué no funciona mi contraseña, todo bien hasta que le agregue eso

 
Vista:
sin imagen de perfil
Val: 14
Ha mantenido su posición en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

No sé por qué no funciona mi contraseña, todo bien hasta que le agregue eso

Publicado por Miguel (5 intervenciones) el 03/04/2020 01:22:07
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include <conio.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
int main() {
	int opc;
mr:
	char pass[10];
	int correcto;
	int intento;
	const char contraseña[] = "1999";
	intento=1;
	correcto = 0;
		printf("Introduce the password:"); get(pass); printf("\n");
	if (strcmp(pass,contraseña)==0) correcto=1;
	while ((correcto==0)&&(intento<3))
	{
intento++;
printf("contraseña incorrecta. %i intento:", intento); gets(pass); printf("\n");
if (strcmp(pass,contraseña)==0) correcto=1;
}
	if (correcto==0) printf("se ha excedido el numero de intentos.");
	else{
	system("cls");
	cout << "\t                             The Planet earth                        \n";
	cout << "\t                          ++++++++++++++++++++++                     \n";
	cout << "\t                      ++++++++++++++++++++++++++++++                 \n";
	cout << "\t                   ++++++++++++++++++++++++++++++++++++              \n";
	cout << "\t                +++++++++++++++++++++++++++++++++++++++++            \n";
	cout << "\t               ++++++++++++++++++++++++++++++++++++++++++++          \n";
	cout << "\t             ++++++++++++++++++++++++++++++++++++++++++++++++        \n";
	cout << "\t           ++++++++++++++°°°°°°°++++++++++++++++++++++++++++++       \n";
	cout << "\t          ++++++++++++++°°°++°°°°°°°°°°++++++++++++++++++++++++      \n";
	cout << "\t          ++++++++++++++°°°++°°°°°°°°°°°°°°+++++++++++++++++++++     \n";
	cout << "\t         ++++++++++++++++°°+++°°°°°°°°°°°°°°+++++++++++++++++++++    \n";
	cout << "\t         +++++++++++++++++°°++°°°°°°°°°°°°°°+++++++++++++++++++++    \n";
	cout << "\t         ++++++++++++++++++++++General Menu°+++++++++++++++++++++    \n";
	cout << "\t         +++++++++++++++++++++++°°°°°°°°°°°°+++++++++++°+++++++++    \n";
	cout << "\t         ++++++++++++++++++++++++°°°°°°°°°°°+++++++++°°°+++++++++    \n";
	cout << "\t         +++++++++++++++++++++++++°°°°°°°°°°°°++++°°°°++++++++++    \n";
	cout << "\t          +++++++++++++++++++++++++°°°°°°°°°°°°°°°°°++++++++++++     \n";
	cout << "\t           +++++++++++++++++++++++++++°°°°°°°°°°+++++++++++++++      \n";
	cout << "\t            ++++++++++++++++++++++++++++++++++++++++++++++++++       \n";
	cout << "\t              ++++++++++++++++++++++++++++++++++++++++++++++         \n";
	cout << "\t               ++++++++++++++++++++++++++++++++++++++++++++          \n";
	cout << "\t                  ++++++++++++++++++++++++++++++++++++++             \n";
	cout << "\t                    +++++++++++++++++++++++++++++++++                \n";
	cout << "\t                        +++++++++++++++++++++++++                    \n";
	cout << "\t                             +++++++++++++++                         \n";
	cout << "\t                                 Geology                             \n";
	cout << "\t                                                                     \n";
 
	cout << "\t\t\t********************************************\n\n";
	cout << "\t\t\t\t ^ Chose one number, please ^  \n\n";
	cout << "\t\t\t********************************************\n\n";
	cout << " 1. Program 16 \n";
	cout << " 2. Program Inch to cm \n";
	cout << " 3. Phrase and Number \n";
	cout << " 4. House hitch \n";
	cin >> opc;
	switch (opc) {     //star to the menu
	case 1:
		cout << "Print from 1 to 10 except the 5 !\n";
		{  // <-- Block
		int i;
		for (i = 1; i <= 10; i++)
			if (i == 5)
				continue;
			else
				printf("%d \n\n", i);
 
		}  // <-- end block
		break;
	case 2:
	{  // <--- Block
		int variable;
 
		cout << "Inches to centimetres!\n";
 
 
		float pulgadas;
 
		cout << "Inches:\n";
		cin >> pulgadas;
 
		cout << pulgadas << " Inches are " << pulgadas * 2.54 << " centimeters" << endl;
 
		}  // <-- end block
	break;
 
	case 3:
		cout << "Repeat the phrase accord to the number!\n";
		{  // <-- block
 
			string phrase;
			int n;
 
			cout << "Introcuce Phrase\n";
			cin >> phrase;
			cout << "...and an number: ";
			cin >> n;
 
			for (int i = 1; i <= n; i++)
				cout << phrase << endl;
 
			}  // <-- endblock
		break;
	case 4:
		cout << "House Hitch!\n";
		{
			float housecost, income;
 
			cout << "\n House Cost: "; cin >> housecost;
			cout << "\n Monthly Income: "; cin >> income;
 
			cout << "\nInitial Payment: ";
			if (income < 8000)
			{
				cout << housecost * 0.15 << endl;
				housecost -= housecost * 0.15;
 
				cout << "\n Monthly payment during 10 years: " << housecost / 10 / 30 << endl;
			}
			else
			{
				cout << housecost * 0.30 << endl;
				housecost -= housecost * 0.30;
 
				cout << "\n Monthly payment during 7 years: " << housecost / 7 / 30 << endl;
			}
		}
		break;
	}
	//End Menu
	cout << "\t*****************************************************************\n";
	cout << "\t Do you want to return at the menu, press 1 for yes or 2 for not\n";
	cout << "\t*****************************************************************\n";
	int resp; cin >> resp;
	if (resp == 1) {
		goto mr;
	}
	else {
		cout << "Babe i'm gonna leave you";
 
	}
}
 
//  Todo lo demás esta bien, hasta el momento en que agrego la contraseña es cuando hay problema y me aparece una lista enorme de problemas
pass
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
sin imagen de perfil
Val: 1.440
Bronce
Ha mantenido su posición en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

No sé por qué no funciona mi contraseña, todo bien hasta que le agregue eso

Publicado por dario (718 intervenciones) el 03/04/2020 05:03:08
Primeramente decidete que lenguaje vas a usar, C o C++ estas mezclando sentencias de los dos lenguajes.
Salu2.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 1.440
Bronce
Ha mantenido su posición en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

No sé por qué no funciona mi contraseña, todo bien hasta que le agregue eso

Publicado por dario (718 intervenciones) el 03/04/2020 11:46:03
Hola, prueba con esto.
Salu2.

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
#include <iostream>
 
using namespace std;
 
int main() {
  string clave,phrase;
  int intentos=1;
  int opc,i,variable,n;
  float pulgadas,housecost,income;
  const string password = "1999";
 
  cout << "Digite la clave: ";
  cin >> clave;
  cout << endl;
 
  if (clave == password) {
    cout << "\t\t\t********************************************\n\n";
    cout << "\t\t\t\t ^ Chose one number, please ^ \n\n";
    cout << "\t\t\t********************************************\n\n";
    cout << " 1. Program 16 \n";
    cout << " 2. Program Inch to cm \n";
    cout << " 3. Phrase and Number \n";
    cout << " 4. House hitch \n";
    cin >> opc;
 
    switch (opc) { //star to the menu
        case 1:
            cout << "Print from 1 to 10 except the 5 !\n";
            for (i = 1; i <= 10; i++) {
                if (i != 5)
                    cout << i << " ";
                else
                    continue;
            }
 
        break;
        case 2:
            cout << "Inches to centimetres!\n";
            cout << "Inches:\n";
            cin >> pulgadas;
            cout << pulgadas << " Inches are " << pulgadas * 2.54 << " centimeters" << endl;
        break;
        case 3:
            cout << "Repeat the phrase accord to the number!\n";
            cout << "Introduce Phrase\n";
            cin >> phrase;
            cout << "...and an number: ";
            cin >> n;
            for (i = 1; i <= n; i++)
                cout << phrase << endl;
        break;
        case 4:
            cout << "House Hitch!\n";
            cout << "\n House Cost: "; cin >> housecost;
            cout << "\n Monthly Income: "; cin >> income;
            cout << "\nInitial Payment: ";
            if (income < 8000)
            {
                cout << housecost * 0.15 << endl;
                housecost -= housecost * 0.15;
                cout << "\n Monthly payment during 10 years: " << housecost / 10 / 30 << endl;
            }
            else
            {
                cout << housecost * 0.30 << endl;
                housecost -= housecost * 0.30;
                cout << "\n Monthly payment during 7 years: " << housecost / 7 / 30 << endl;
            }
 
        break;
    }
  }
  else {
    while (clave != "1999" && intentos < 4) {
      cout << "Intento # " << intentos << endl;
      cout << "Clave erronea, intente nuevamente" << endl << endl;
      cout << "Digite la clave: ";
      cin >> clave;
      intentos++;
 
      if (intentos > 3)
        cout << "Excedio el limite de intentos" << endl;
    }
  }
 
  return 0;
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar