- 1
А вот операторов сравнения между всеми типами умных указателей, я как понял, нету, и даже по стандарту.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
А вот операторов сравнения между всеми типами умных указателей, я как понял, нету, и даже по стандарту.
0
#include "pch.h"
#include <iostream>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
using namespace std;
int n=0, m=0, a[10][10];
void inputSize();
void input();
void out(int);
void problem();
bool just(int);
void menu();
int main()
{
setlocale(0, "rus");
menu();
return 0;
}
void inputSize() {
system("cls");
cout << "количество строк = "; cin >> n;
cout << "количество столбцов = "; cin >> m;
}
void input() {
system("cls");
if (n == 0 || m == 0) {
cout << "размер массива задан по умолчанию: 3х3";
n = m = 3;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << "a[" << i + 1 << "][" << j + 1 << "] = "; cin >> a[i][j];
}
}
}
void out(int x = 0 ) {
system("cls");
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << setw(7) << a[i][j];
}
cout << endl;
}
cout << endl;
system("pause");
}
void problem() {
system("cls");
int sum = 0, k = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (just(a[i][j])) {
cout << "a[" << i + 1 << "][" << j + 1 << "] ";
sum += a[i][j];
k++;
}
}
}
if (sum == 0) cout << "нет простых чисел";
else if (sum % k == 0) cout << "ср. арифм. - целое"; else cout << "ср. арифм - не целое";
_getch();
}
bool just(int n) {
if (n == 1)return false;
int c = sqrt(n);
for (int i = 2; i <= c; i++) if (n%i == 0) return false;
return true;
}
void menu() {
system("cls");
int ch = 0;
while (ch != 5) {
cout << " МЕНЮ\n\n";
cout << "1. ввод размера массива\n";
cout << "2. ввод массива\n";
cout << "3. вывод массива\n";
cout << "4. решение задачи\n";
cout << "5. выход\n\n";
cout << ">>"; cin >> ch;
if (ch == 1) inputSize();
if (ch == 2) input();
if (ch == 3) out();
if (ch == 4) problem();
if (ch == 5) break;
system("cls");
}
}
0
if (res / 2 < ans) {
ans = res / 2;
}
0
#include <iostream> #include <cmath> #include <iomanip> #include <random> using namespace std;
int main()
{
setlocale(LC_ALL, "Rus");
double n; cout << "Введите точность вычисления: "; cin >> n;
while (n < 0.000001 || n > 1)
{
cout << "Веденное не соответствует условию" << "\nВведите точность вычислений: " << endl; cin >> n;
}
random_device generator; uniform_real_distribution<double> distribution(-700, 700); //потому что функция "sinh" не считает > 700 double x = distribution(generator) cout << "На множестве R выбран x, равный: " << x << "\n";
double sum = 0.0 double a = x; double t = 1;
while (abs(a) >= n)
{
sum += a; a *= (x * x / ((t + 1) * (t + 2))); t += 2;
}
double func = sinh(x); double diff = abs(sum - func); cout << setprecision(ceil(log10(1 / n))) << "Результат функции: " << func <<"\nРезультат просчета ряда: " << sum << endl; cout << "Погрешность составляет: " << diff << endl;
return 0;
0
#include <iostream>
#include <cmath>
#include <iomanip>
#include <random>
using namespace std;
int main()
{
setlocale(LC_ALL, "Rus");
double n;
cout << "Введите точность вычисления: ";
cin >> n;
while (n < 0.000001 || n > 1)
{
cout << "Веденное не соответствует условию" << "\nВведите точность вычислений: " << endl;
cin >> n;
}
//Рандомные числа с промежутком
random_device generator;
uniform_real_distribution<double> distribution(-700, 700); //потому что функция "sinh" не считает > 700
double x = distribution(generator);
cout << "На множестве R выбран x, равный: " << x << "\n";
//Подсчёт формулы
double sum = 0.0;
double a = x;
double t = 1;
while (abs(a) >= n)
{
sum += a;
a *= (x * x / ((t + 1) * (t + 2)));
t += 2;
}
//Функция, сравнение, погрешность
double func = sinh(x);
double diff = abs(sum - func);
cout << setprecision(ceil(log10(1 / n))) << "Результат функции: " << func <<"\nРезультат просчета ряда: " << sum << endl;
cout << "Погрешность составляет: " << diff << endl;
return 0;
+1
#include "pch.h"
#include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <ctime>
using namespace std;
int main()
{
setlocale(0, "rus");
int n, a[1000], max, c;
cout << "число элементов: "; cin >> n;
srand(time(0));
cout << "\nчисла массива:\n";
for (int i = 0; i < n; i++) {
a[i] = rand() % 2000 -1000;
cout << a[i] << " ";
if (i == 0) max = abs(a[i]); else if (abs(a[i]) > max) max = abs(a[i]);
}
cout << "\n\nабс. максимум = " << max << endl;
for (int i = 0; i < n; i++) {
for (int j = n-1; j > 0; j--) {
if (a[j - 1] < a[j]) {
c = a[j - 1];
a[j - 1] = a[j];
a[j] = c;
}
}
}
cout << "\nотсортированный массив:\n";
for (int i = 0; i < n; i++) {
cout << a[i]<<" ";
}
_getch();
return 0;
}
+1
// File icontact.h
// Describes a contact in the address book
class IContact
{
public:
virtual ~IContact();
virtual void ...
...
void setContact(const QString& contact);
...
private:
QString m_contact;
// ... other fields ...
};
// File icontact.cpp
void IContact::setContact(const QString &contact)
{
m_contact = contact;
}
"Ну и че тут непонятного?" (Senior software developer, 8+ years of experience)
0
In file included from /usr/include/c++/5.5.0/string:52:0,
from /usr/include/c++/5.5.0/bits/locale_classes.h:40,
from /usr/include/c++/5.5.0/bits/ios_base.h:41,
from /usr/include/c++/5.5.0/ios:42,
from /usr/include/c++/5.5.0/ostream:38,
from /usr/include/c++/5.5.0/iostream:39,
from 1.cpp:1:
/usr/include/c++/5.5.0/bits/basic_string.h:5275:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator<<(basic_ostream<_CharT, _Traits>& __os,
^
/usr/include/c++/5.5.0/bits/basic_string.h:5275:5: note: template argument deduction/substitution failed:
1.cpp:16:18: note: mismatched types ‘std::basic_ostream<_CharT, _Traits>’
давайте обсирать С++
+4
// File.cpp
QString File::size() const
{
return QString::number(QFileInfo(m_path).size());
}
// ... somewhere in the code...
File* message = ...
...
if (message->size() == "0")
return;
Commit b1aef142 "Refactoring"
Р - Рефакторинг
0
#include <stdio.h>
struct Gost {
int x = 42;
};
int main () {
Gost gst;
printf("%d\n", gst); // 42
}
http://ideone.com/fB26cs
Уб ли это?