Maritimo 15 Junior Poster in Training

I recomend you to use the function int toupper( int ch ) defined in header <cctype>

cambalinho commented: thanks +3
Maritimo 15 Junior Poster in Training

Yes, it is perfectly possible to solve that problem in C++.

Maritimo 15 Junior Poster in Training

Do you want that someone make your homework?

Maritimo 15 Junior Poster in Training

2) Are there any memory-specific issues that the below code will encounter?

Yes, your first call to push_back will fail, for example, because iterator first do not point to any memory. To solve this, you must create the constructors and destructor.

4) My "String List" is not complete, but are there any other glaring issues I might look into?

Yes. You must create basically seven member functions to your String_list that are fundamental and you didn't:

  1. Ordinary constructors
  2. Default constructor
  3. Copy constructor
  4. Move constructor
  5. Copy assigmment
  6. Move assigmment
  7. Destructor

In all of your classes you always must take care of all of this seven member functions. You have several alternatives to do this, you can code all of them, leave some of them to be created by default or specify that they must not be created with = delete in c++11.

You must define a group of "invariants" like: 1) iterator first point to an array of strings pointers, 2) iterator last point to the last plus one string pointer and 3) list_size indicates the number of elements. You must initialize your String_list class forcing this invariants with all of your contructors and keep this invariants with all of your member functions. Finally you must liberate all your resources with your destructor. Your String_list is not doing nothing of these!!

Maritimo 15 Junior Poster in Training

1) Is this statement correct: In memory, elements of an array are stored "against" each other (I think more precisely, contigious space is allocated for them?) and a pointer to an array points to the first element.

Yes it is correct.

Maritimo 15 Junior Poster in Training

First I recommend making your board two rows bigger and two columns wider so you will not change your code when you are at the border. You must 'mark' the boxes that are out of the bord with some special value.
Then, if you are at the position r,c, for example, the diagonals will be at positions r+1,c+1, r+1,c-1, r-1,c+1 and r-1,c-1.
I don't know if this answer your question or I am not undertanding you.

Maritimo 15 Junior Poster in Training

I don't think this web is to teach how to crack a programm. Anyway, if you want to crack a code, you need to know a lot that seems you don't. So I recomend don't try to solve this here, you must study a lot. Your first step shuld be to learn assembler.

RikTelner commented: I'm here to get knowledge, if you're here to throw me objections then go somewhere else. Nobody talks here about me learning how to crack, I found it interesting and then I found new questions on horizon, which I post here. +0
Maritimo 15 Junior Poster in Training

Replace

#define TRUE = 1;
#define FALSE = 0;

with

#define TRUE 1;
#define FALSE 0;

I don't know what you program must do but with this replacements there should not be more compiler errors. Good luck.

Maritimo 15 Junior Poster in Training

Taking into account that:

If a number N ends in zero then the remainder of N integer divided by ten is zero

You could count the number of zeroes inside a number N with the following algorithm:

Initialize Counter to zero
While N is greather than zero
  IF N ends in zero then increment Counter
  Integer divide N by ten
End while
Print Counter.
Maritimo 15 Junior Poster in Training

I recomend you to use a little endian representation of your string numbers, because it is easy to manage the carry. You can try something like:

string add(const string& n1, const string& n2)
{
  // Add two string numbers in little-endian format (reversed)

  const string& min = n1.size()<n2.size() ? n1 : n2;
  const string& max = n1.size()<n2.size() ? n2 : n1;

  int minsize = min.size();
  int maxsize = max.size();

  string res;
  res.reserve(maxsize+1); // This is for optimization purpose only.

  int c=0;
  for(int j=0; j<minsize; ++j)
    {
      int s = c + max[j] + min[j] - 2*'0';
      c = s/10;
      res += '0' + s%10;
    }
  for(int j=minsize; j<maxsize; ++j)
    {
      int s = c + max[j] - '0';
      c = s/10;
      res += '0' + s%10;
    }
  if(c) res += '0' + c;

  return res;
}

To use this, you need to reverse your string numbers before to call add, and after to get the result.

For example, to add 84 with 456 you must call:
string res = add("48", "654"); giving res == 045.
The finel answer is the reverse of 045 which is 540.
That is 84 + 456 = 540.

Maritimo 15 Junior Poster in Training

A function can return a value, for example:
int addOne(int a) {return a+1;}
and be used like:
b = addOne(b);

Also it can not return a value, for example:
void addOne(int& a) {a = a+1;}
and be used like:
addOne(b);

In this case, you have both alternatives and you can choose between them depending your personal taste, the clarity, etc.

Exists other functions that never need to return nothing like:
void printLine(int n) {while(n-->0) std::cout '-'; std::cout << std::endl;}
and be used like:
printLine(20);
to write a Line of 20 - : --------------------.

Maritimo 15 Junior Poster in Training

I don´t think thos is a C++ problem. It seems an operating system problem. Which is your operating system?

Maritimo 15 Junior Poster in Training

Yap, you are wright.
I wrote:

while(k < 2*n-1)

and

double s = f(a) + f(b);

Insted of:

while(k <= 2*n-1)  

and

double s = f(a) - f(b);

Sorry.

Also, in the future i´ll try not to give the complete answer.

Maritimo 15 Junior Poster in Training

This should work:

#include <iostream>

using namespace std;

int main()
{
  int var;
  cout << "please enter any integer" << endl;

  while(!(cin>>var))
    {
      cin.clear();
      cin.ignore(1000,'\n');
      cout << "Error, enter the right thing" << endl;
    }

  cout << "You entered: " << var << endl;

  return 0;
}

Enjoy :)

Maritimo 15 Junior Poster in Training

The analitical answer is 0.440244, so this is the limit that you must arrive with a lot of intervals.

Here you have your code modified to the right answer:

#include <iostream>
#include <cmath>

using namespace std;

double f(double x)
{
  return ((0.6369)*sin(sin(x))*sin(x));
}

int main()
{
  double a = 0.0;
  double b = 1.5707963267948966;
  int n = 200000;
  double h = (b-a)/(2*n);
  double s = f(a) + f(b);
  int k = 1;
  double x;

  while(k < 2*n-1)
    {
      x = a+h*k;
      s+= 4*f(x)+2*f(x+h);
      k+= 2;
    }

  cout << "integral is equal " << s*h/3;
}

With n=20 I obtain 0.412218
With n=200 I obtain 0.437438
With n=2000 I obtain 0.439964
With n=20000 I obtain 0.440216
With n=200000 I obtain 0.440241

Enjoy :)