Browse Source

comment 2

Dmitry 3 years ago
parent
commit
93f540972b
3 changed files with 45 additions and 20 deletions
  1. 2 2
      cStack.cpp
  2. 8 6
      cStack.h
  3. 35 12
      main.cpp

+ 2 - 2
cStack.cpp

@@ -27,7 +27,7 @@ int  cStack::stack_size () {
 }
 
 void cStack::clean_stack () {
-	for (int i = 0; i <  MAX_SIZE; i++) {
+	for (int i = 0; i <  MAX_STACK_SIZE; i++) {
 		st [i] = 0;
 	}
 	top = 0;
@@ -38,7 +38,7 @@ void cStack::show_stack () {
 	
 	cout << "top = " << top << endl;
 	
-	for (int i = 0; i < MAX_SIZE; i++ ) {
+	for (int i = 0; i < MAX_STACK_SIZE; i++ ) {
 		cout << "st" << i << " " << st [i] << "  ";
 	}
 	cout << endl;

+ 8 - 6
cStack.h

@@ -1,12 +1,13 @@
-//#ifndef __CSTACK_H__
-//#define __CSTACK_H__
-unsigned	const int MAX_SIZE = 20;
+#ifndef __CSTACK_H__
+#define __CSTACK_H__
+
+unsigned	const int MAX_STACK_SIZE = 20;
 
 class cStack {
 	private:
 
-		double st [MAX_SIZE];
-		int top;
+		double st [MAX_STACK_SIZE];
+		unsigned int top;
 		
 	public:
 		cStack();
@@ -19,6 +20,7 @@ class cStack {
 		int stack_size ();
 		
 		void clean_stack ();
+	
 		void show_stack ();
 };
-//#endif
+#endif

+ 35 - 12
main.cpp

@@ -2,13 +2,17 @@
 #include <string>
 #include <cstdio>
 #include <cmath>
+#include <cstring>
 
 #include "cStack.h"
 
 unsigned const int FIRST_MASS = 100; 
 using namespace std;
+
+using std::cout;
 		
 		cStack cStack1;
+		
 void abstract ();
 double get_number (char *mass);
 
@@ -18,18 +22,37 @@ double addition ();
 double subtraction ();
  
 int main () {
-		
-	abstract ();
 	
 	while (true) { 
 	
-		int Size_Ent_Comand = 0;
+	
+	char comand[12];
+	
+	double number = 0;
+	
+	scanf( "%s%le", &comand, &number);
+	
+	cout << "comand = " <<  comand << "   number= " << number << endl;
+	
+	
+	char rrr[3][55] = {"pule","Ls", "CC"};
+	
+	cout << "ewef " << rrr[0] << endl;
+	
+	if (0 == strcmp(rrr[1], comand)) {
+			cout << "Its work \n";
+	}
+	
+ 	/*
+	 
 		double number;
 	
 		char mass[FIRST_MASS];
+		
 		for (int i = 0; i < FIRST_MASS; i++ ) {
 			mass [i] = ' ';
 		}
+		
 		gets(mass);
 
 		if (mass [0] == 'p' && mass [1] == 'u' && mass [2] == 's' && mass [3] == 'h' && mass [4] == ' ') {
@@ -84,10 +107,12 @@ int main () {
 		
 		if (mass [0] == 'e' && mass [1] == 'n' && mass [2] == 'd') {
 			cout << "rezalt = " << cStack1.pop () << endl;
-			goto metka1 ;
+		//	goto metka1 ;
+			break;
 		}
+		*/
 	}
-	metka1:	
+	
 	
 	return 0;
 }
@@ -123,16 +148,14 @@ double get_number (char *mass) {
 	return num;
 }
 
+
 double cosine () {
 	
-	double rezalt = -999999;
-	double element = 0;
-	
-	element = cStack1.pop ();
-	cStack1.push (rezalt = cos (element) );
-	
+	double result = cos (cStack1.pop ());
+	cStack1.push (result);
+	 
 	cout << "OK \n";
-	return rezalt;
+	return result;
 }
 
 double sinus () {