C++ Симметричное словоhttps://www.cyberforum.ru/ cpp-beginners/ thread205097.html Найти во введённом тексте самое длинное симметричное слово, т.е. слово, которое слева направо и справа налево читается одинаково. Считать, что слова в тексте отделены друг от друга одним пробелом.
#include "stdafx.h"
#include <string.h>
#include <iostream>
using namespace std;
int main ()
{
int i,p,q=0,s,max=0,c=0;
const int n=256;
char mas,mas2,mas3;
C++ Функторы и алгоритмы stl Добрый день! Интересует такой вопрос.
Я хочу, используя стандартный алгоритм стл for_each() и функтор, определить наибольший элемент в векторе. Т.е. функтор должен просматривать последовательность и в конце выводить значение наибольшего элемента. Написал нижеследующий код. Проблема заключается в том, что написанный мной функтор содержит подсчет просмотренных элементов (int i), чтобы сделать...
C++ функции пользовательскиеПомогите решить задачи в С++ (я в этом начиющий):
1)Вывести на экран таблицу степеней двойки: 2, где n изменяется от -к до 10. Операцию возведения целого числа в целую степень оформить в виде функции.(Пользователькие функции)
2)Из положительных значений двух целочисленных массивов различной размерности сформировать общий массив. Найти среднее арифметическое элементов, расположенных в массиве до...https://www.cyberforum.ru/ cpp-beginners/ thread205084.html
C++ Массив работает но криво (https://www.cyberforum.ru/ cpp-beginners/ thread205083.html 1 . В одномерном массиве, состоящем из и целых элементов, вычислить:
1) К максимальных элементов массива;
2) Проверить массив на упорядоченность;
Преобразовать массив таким образом, чтобы в первой его половине располага¬лись элементы, стоявшие в нечетных позициях, а во второй половине — элемен¬ты, стоявшие в четных позициях.
Составить программу, которая из введенной последовательности N...
C++ пользавательские функции Помогите решить задачи в С++ (я в этом начиющий):
1)Вывести на экран таблицу степеней двойки: 2, где n изменяется от -к до 10. Операцию возведения целого числа в целую степень оформить в виде функции.(Пользователькие функции)
2)Из положительных значений двух целочисленных массивов различной размерности сформировать общий массив. Найти среднее арифметическое элементов, расположенных в массиве до...
C++ Работа со строками [String.h]Написать програму при помощи библиотеки String.h
Дана строка S1.....Sn (n за ранее не известно) нужно:
1)определить количество пробелов среди S1....Sn.
2)Выяснить входит ли в последовательность буква ю.
3)Имеются ли в строке буквы входящие в слово " Шина ".
4)выяснить имеються ли в строке пара соседствующих букв но или он.
И это всё вывести на экран..
Добавлено через 19 часов 12 минут...https://www.cyberforum.ru/ cpp-beginners/ thread205080.html
C++ пользовательские функцииhttps://www.cyberforum.ru/ cpp-beginners/ thread205079.html Помогите решить задачи в С++ (я в этом начиющий):
1)Вывести на экран таблицу степеней двойки: 2, где n изменяется от -к до 10. Операцию возведения целого числа в целую степень оформить в виде функции.(Пользователькие функции)
2)Из положительных значений двух целочисленных массивов различной размерности сформировать общий массив. Найти среднее арифметическое элементов, расположенных в массиве до...
C++ Переписать пять первых положительных элементов массива подряд в массив У Люди добрые, помогите решить пару задач на С++ на одномерные и двумерные массивы (я новичок и мало что в этом соображаю):
1)Дан массив Х. Переписать пять первых положительных элементов массива подряд в массив У. Найти максимальный элемент массива Х.
2)Найти наибольший и наименьший элементы вещественного массива. Если таких элементов несколько, определить, сколько их. Создать фйнкции для...
C++ Проверка и доработка кода.https://www.cyberforum.ru/ cpp-beginners/ thread205063.html Написал программу попробовал откомпилировать в Visual Studio 2010. Стало выдавать разнообразные ошибки. Помогите пожалуйста исправить ошибки. Вот само задание: Дана матрица A(n,m). Найти максимальное простое число из введенных.
А вот код:
#include <stdafx.h>
#include <conio.h>
#include <iostream>
#include <stdio.h>
using namespace std;
void vvod(int &n, int &m, double A); //функция...
C++ исправьте ошибку,пожалуйстаhttps://www.cyberforum.ru/ cpp-beginners/ thread205047.html Вычислить среднее значение элементов, расположенных в массиве между первым и послед-ним нулевыми элементами. Поменять местами максимальный и минимальный элементы. Создать функции для вычисления среднего значения, определения номеров максимума и м
// ham.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <math.h>#include <stdio.h>#include <string.h>#define MAXINT 65536#define SIZE 100int arr[SIZE][SIZE];// a global array , to contain table information int ele=0,ind=0;// indices to be used in above arrayvoid summ(int i){/* The method to initialize contents of global array by power of 2's sum for each entry */int j=0;//index noif(isPow2(i)){/*input no i is of power of 2's form like 1,2,4,8,16...*/
arr[ele][ind]=calcPow(i);/*calculate what's the power of 2 , in the no, & store to global array*/
ind++;}else{/*input no i is NOT of power of 2's form */
j=findLowerOf2(i);/* try to find just last no , which is of form of power of 2 */
arr[ele][ind]=calcPow(j);/* again calculate the power*/
ind++;
i=i-j;/* differnce in the no & the last no which is of form of power of 2 *//*now call method recursively for the new no (i=i-j) */
summ(i);}}int isPow2(int i){/*if input no is power of two retrun 1 , else 0*/if(MAXINT % i==0)return1;//truereturn0;//false}int calcPow(int i){/*Thism ethod returns , what is power of 2 , in a no. which is of form 2 to the power p *//* return p , from input of format 2^p */int count=-1;/* validate */if(!isPow2(i))printf("flow error...");elsewhile(i>0){
i/=2;
count++;}return count;}int findLowerOf2(int i){/*a function to calculate the no , JUST below i , which is power of 2 */int count=-1;if(isPow2(i))returnpow(2,i);elsewhile(i>0){
i/=2;
count++;}returnpow(2,count);}void callSumm(int i){/* A method to call summ() method , with assertion that all global parameters are incremented at each call to summ() */
ind=0;
summ(i);
arr[ele][ind++]=-1;
ele++;}void dieError(){/* If failure , exit the program*/exit(1);}int howManyTimes(int val,int a[]){/* a method to check that how many times no val is occuring in array a[] */int i,count=0;for(i=0;a[i]!=-1;i++)if(a[i]==val)
count++;return count;}void checkInput(int argc,char str[]){int i=0;if(argc<2){printf("usage: filename.o 'The code string' ");printf("ex.a.out 110110");
dieError();}for(i=0;i<strlen(str);i++)if(!(str[i]=='0'|| str[i]=='1')){printf("Please enter a binary string only.....");
dieError();}}int calr(int m){/*Method to calculate checksum bits for given m , databits */int r=0;for(r=0;r<=m;r++)if(m <=pow(2,r)-1-r)return r;}int isEven(int i){return i%2==0;}int main(int argc,char*argv[]){/* Declaretions ...*//* flag & index variables*/int i,j,k=0,flag,temp;/* The output codeword container */char coded[SIZE];int len;//total length of coded wordint m;//code bitsint r;//check bits/* to associate & contain equations of checkbits */int count[SIZE][SIZE];/* validate input */
checkInput(argc,argv[1]);/*calculate no of check bits required n thus total length */
m=strlen(argv[1]);
r=calr(m);
len=m+r;/* Fill the global container , according to the size info of m,r & len */for(i=1;i<=len;i++)
callSumm(i);for(j=0,k=0;j<r;j++){for(i=0,k=0;i<len;i++)if(howManyTimes(j,arr[i]))
count[j][k++]=i+1;
count[j][k]=-1;}/*Fill the code word....,except check bits*/for(i=0,j=0;j<len;j++){if(!isPow2(j+1))
coded[j]=argv[1][i++];else
coded[j]='x';//initialize checkbits by character x }/* Now ********** Frame all equations & solve them & fill entries in coded table accordingly */for(i=0;i<r;i++){for(flag=0,j=1;count[i][j]!=-1;j++){
temp=count[i][j]-1;if(coded[temp]=='1')
flag+=1;elseif(coded[temp]=='0')
flag+=0;}
temp=count[i][0]-1;if(isEven(flag))
coded[temp]='0';else
coded[temp]='1';}printf("The Hamming coded word for your data is ");for(i=0;i<len;i++)printf("%c",coded[i]);printf("");}
а выходит
1>------ Build started: Project: ham, Configuration: Debug Win32 ------
1>Compiling...
1>ham.cpp
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(20) : error C3861: 'isPow2': identifier not found
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(23) : error C3861: 'calcPow': identifier not found
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(30) : error C3861: 'findLowerOf2': identifier not found
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(33) : error C3861: 'calcPow': identifier not found
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(75) : error C2668: 'pow' : ambiguous call to overloaded function
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(575): could be 'long double pow(long double,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(527): or 'float pow(float,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(489): or 'double pow(double,int)'
1> while trying to match the argument list '(int, int)'
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(84) : error C2668: 'pow' : ambiguous call to overloaded function
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(575): could be 'long double pow(long double,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(527): or 'float pow(float,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(489): or 'double pow(double,int)'
1> while trying to match the argument list '(int, int)'
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(100) : error C3861: 'exit': identifier not found
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(121) : error C2001: newline in constant
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(122) : error C2146: syntax error : missing ')' before identifier 'ex'
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(124) : error C2001: newline in constant
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(127) : warning C4018: '<' : signed/unsigned mismatch
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(130) : error C2001: newline in constant
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(131) : error C2001: newline in constant
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(132) : error C2146: syntax error : missing ')' before identifier 'dieError'
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(144) : error C2668: 'pow' : ambiguous call to overloaded function
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(575): could be 'long double pow(long double,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(527): or 'float pow(float,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(489): or 'double pow(double,int)'
1> while trying to match the argument list '(int, int)'
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(221) : error C2001: newline in constant
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(222) : error C2001: newline in constant
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(223) : error C2143: syntax error : missing ')' before 'for'
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(223) : warning C4552: '<' : operator has no effect; expected operator with side-effect
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(223) : error C2143: syntax error : missing ';' before ')'
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(223) : error C2143: syntax error : missing ';' before ')'
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(225) : error C2001: newline in constant
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(226) : error C2001: newline in constant
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(228) : error C2143: syntax error : missing ')' before '}'
1>d:\мои документы\visual studio 2008\projects\ham\ham\ham.cpp(228) : error C2143: syntax error : missing ';' before '}'
1>Build log was saved at "file://d:\мои документы\Visual Studio 2008\Projects\ham\ham\Debug\BuildLog.htm"
1>ham - 23 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========