Answers for "C++"

C
0

c++

// Your First C++ Program

#include <iostream>

int main() {
    std::cout << "Hello World!";
    return 0;
}
Posted by: Guest on November-30-2020
1

c++

#ifndef POLYNOMIAL_H_
#define POLYNOMIAL_H_

#include <iostream>
#include <math.h>  // fabs, pow

#include "vector_t.h"
#include "sparse_vector_t.h"

// Clase para polinomios basados en vectores densos de doubles
class Polynomial : public vector_t<double> {
 public:
  // constructores
  Polynomial(const int n = 0) : vector_t<double>(n) {};
  Polynomial(const Polynomial& pol)
      : vector_t<double>(pol) {}; // constructor de copia

  // destructor
  ~Polynomial() {};

  // E/S
  void Write(std::ostream& = std::cout, const double eps = EPS) const;
  
  // operaciones
  double Eval(const double) const;
  bool IsEqual(const Polynomial&, const double = EPS) const;
 };


// Clase para polinomios basados en vectores dispersos
class SparsePolynomial : public sparse_vector_t {
 public:
  // constructores
  SparsePolynomial(const int n = 0) : sparse_vector_t(n) {};
  SparsePolynomial(const Polynomial& pol) : sparse_vector_t(pol) {};
  SparsePolynomial(const SparsePolynomial&);  // constructor de copia

  // destructor
  ~SparsePolynomial() {};

  // E/S
  void Write(std::ostream& = std::cout) const;
  
  // operaciones
  double Eval(const double) const;
  bool IsEqual(const SparsePolynomial&, const double = EPS) const;
  bool IsEqual(const Polynomial&, const double = EPS) const;
};

// E/S
void Polynomial::Write(std::ostream& os, const double eps) const {
  os << get_size() << ": [ ";
  bool first{true};
  for (int i{0}; i < get_size(); i++)
    if (IsNotZero(at(i), eps)) {
      os << (!first ? " + " : "") << at(i)
	 << (i > 1 ? " x^" : (i == 1) ? " x" : "");
      if (i > 1)
	os << i;
      first = false;
    }
  os << " ]" << std::endl;
}

std::ostream& operator<<(std::ostream& os, const Polynomial& p) {
  p.Write(os);
  return os;
}

// Operaciones con polinomios

// Evaluación de un polinomio representado por vector denso
double Polynomial::Eval(const double x) const {
  double result{0.0};
  // poner el código aquí
  return result;
}

// Comparación si son iguales dos polinomios representados por vectores densos
bool Polynomial::IsEqual(const Polynomial& pol, const double eps) const {
  bool differents = false;
  // poner el código aquí
  return !differents;
}

// constructor de copia
SparsePolynomial::SparsePolynomial(const SparsePolynomial& spol) {
  *this = spol;   // se invoca directamente al operator=
}

// E/S
void SparsePolynomial::Write(std::ostream& os) const {
  os << get_n() << "(" << get_nz() << "): [ ";
  bool first{true};
  for (int i{0}; i < get_nz(); i++) {
    int inx{at(i).get_inx()};
    os << (!first ? " + " : "") << at(i).get_val()
       << (inx > 1 ? " x^" : (inx == 1) ? " x" : "");
    if (inx > 1)
      os << inx;
    first = false;
  }
  os << " ]" << std::endl;
}

std::ostream& operator<<(std::ostream& os, const SparsePolynomial& p) {
  p.Write(os);
  return os;
}

// Operaciones con polinomios

// Evaluación de un polinomio representado por vector disperso
double SparsePolynomial::Eval(const double x) const {
  double result{0.0};
  // poner el código aquí
  return result;
}

// Comparación si son iguales dos polinomios representados por vectores dispersos
bool SparsePolynomial::IsEqual(const SparsePolynomial& spol
			       , const double eps) const {
  bool differents = false;
  // poner el código aquí
  return !differents;
}

// Comparación si son iguales dos polinomios representados por
// vector disperso y vector denso
bool SparsePolynomial::IsEqual(const Polynomial& pol, const double eps) const {
  bool differents = false;
  // poner el código aquí
  return !differents;
}


#endif  // POLYNOMIAL_H_
Posted by: Guest on March-22-2021
3

C++

Better than my grades
Posted by: Guest on October-13-2020
1

c++

assert((std::is_same_v<int, int>))
Posted by: Guest on April-15-2021
0

c++

#include <bits/stdc++.h>
using namespace std;
	
int main() {
	
	return 0;
}
Posted by: Guest on December-03-2020
6

C++

C++ is a general-purpose programming language created by Bjarne 
Stroustrup as an extension of the C programming language, or 
"C with Classes".

//as you can also see to your right ---------------------->

C++ still qualifies as a high-level languge, yet the rise of 
languages like Ruby and Java have given capabilities that sway
people's opinion towards what is and is not "high-level". 

Yet high-level simply means it's farther from machine code and closer 
to human-readable form. Hence the need for a compiler/interpreter.

So don't get too worked up about granular specifics.
Posted by: Guest on May-20-2020
6

c++

C++ is a high-level, general-purpose programming language.

//totally not right there ----------------------------------->
Posted by: Guest on March-21-2020
1

c++

#include <iostream>

int main() {
	std::cout << "Hello, world!" << std::endl;
	return 0;
}
Posted by: Guest on July-16-2020
1

c++

God's language
Posted by: Guest on October-20-2020
0

c++

#include<iostream>
#include<cmath>
using namespace std;
double hypotenuse(double s1, double s2){
	double h = pow(s1, 2) + pow(s2, 2);
	return sqrt(h);
}


int main(){
	cout<<"Hypotenus: "<<hypotenuse(3,4)<<endl;
	cout<<"Hypotenus: "<<hypotenuse(5,12)<<endl;
	cout<<"Hypotenus: "<<hypotenuse(8,15)<<endl;
}
Posted by: Guest on October-07-2021

Code answers related to "C"

Browse Popular Code Answers by Language