I am wondering why this is not matching. I tested my regular expression on notepad2 and it matches fine.
std::string line = " 10 0 5 0";
std::regex rgx("\s+\d+\s+\d+\s+\d+\s+\d+");
if (regex_match(line, rgx))
{
// do something...
int a = 2;
}
I am doing my homework regarding calculation in c++.
I am confused by the below question.
Int A=2 B=3 C=4
B-C && (B-A) /C
I think the answer is 0 because the first part is negative.
But,my friends say the answer is 1 because -1 not mean false.
I want to ask which answer is right?
Thanks.
I have a minor question about this diagram I'm hoping someone can clear up for me.
The deque has initial capacity 4. The following operations are performed.
push_back(1)
push_back(2)
push_back(3)
pop_front()
pop_front()
push_back(4)
push_front(5)
push_front(6)
push_front(7)
final answer...
Homework Statement
I'm to write a program that calculates GPA using loops to allow numerous inputs and using Error checking to be sure that inputs are valid.
I'm having trouble figuring out how to make my loop repeat if a the input is invalid.
And I'm also having a little trouble with the...
Okay, in this thread I'm going to attempt some problems and I would appreciate it if the C++ purists could offer feedback. I Googled to get some ideas for problems. Here's a preview:
Eliminate whitespace from a string
Remove duplicate characters from a string (e.g. "AAA BBB" -> "A B")...
I have a homework assignment that requires me to write a program in c++ to calculate GPA. The assignment wants then input of the grade to be in terms of just A B C, etc.. I'm just having trouble assigning a number value to the user input ie when the user inputs an A for their grade, I need the...
These are some functions I'm using to encode and decode text.
bitstring returns a string of bits representing the ascii values of the characters in the string passed to the function. For example, passing in "Hi" changes it to "0100100001101001" since (int)'H'=72=01001000 and...
Hello All,
I know that this post is very old, but I have a similar question. I believe that it is very relevant and there should be copious material on the net, but I have been unable to find it.
I am trying to port a C++ project into Android. My project uses NTL, GMP, and OpenSSL. I am...
Homework Statement
To write a C++ program to find the factorial of the number input 'a'.
Homework Equations
the factorial evaluated is denoted as 'f'
i is the counter
The Attempt at a Solution
Pls check if my program is correct...(here f is the value of factorial and a is the...
Hi, I'm having a serious trouble when I compile my code :
#include <iostream>
using namespace std;
int main()
{
string nom("x");
cout << "Vous avez quel age ?";
cin >> nom;
cout << "Vous avez-vous donc" << nom << "ans?" ;
return 0 ;
}
Here's the resume ; I click on compile&run...
Hi. I am finishing my last year in High School and I have a question about programming. For a year or two I had been taught Free Pascal but the last year (grade 12) we have been taught some C++. My C++ knowledge is not as wide as it could or probably should be but I am familiar with the basics...
I was wondering some things I could try to increase my skill in programming using physics problems. I'm not interested in a physics engine or anything super advanced like that, just some fun programming projects (ie the physics makes it fun, for me).
I would say I'm still a beginner in C++...
Hello all,
I'm not really a programmer at all, but I learned c++ for a while so I can do basic stuff. Having just finished my linear algebra class I suddenly had an urge to write myself a simple matrix solver. I knew it wouldn't be easy (especially because of my lack of skill) but I was...
I need to make a karnaugh map for 4 variables(there is no need to involve don't care terms) which gives the output as the simplified function. There's no need to literally display the map itself I only need an algorithm that takes the input as min terms and displays the simplified output. Anyone...
Hi I have this small doubt. i am not good in C . i like to bring i,j,pi values to subroutine and bring back Asi to main program. how to write ! Plz help..
#include <stdlib.h>
#include <math.h>
double A_operate(int i,int j)
void main()
{
double Ai, pi[10][10],r[10][10];
int i,j,n,m;
n=6...
Hi
I have written an extensive simulation in C++ and when I run it on my quad-core machine, only a single core is used (on Windows). This is because my code is not parallelized.
I'm not familiar in any way with code running in parallel, except in Matlab where is happens almost...
I want to know, how to make a CLASS FUNCTION to return a STRING.
For example, taken that all variables are declared correctly.
string personType::get() const
{
return firstName + " " + lastName;
}
Hello there!
I typed this code and saved it as a .c file
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
int a;
while(1)
{
if (kbhit())
{
system("cls");
printf("%d...
I am currently in high school and doing a lot of self study. I plan on going into physics in university and I was thinking about learning code, or at least becoming familiar with it. I have decided on C++ and I was wondering what are the best books for learning it on one's own. I don't know if...
Homework Statement
a.
Define an array with a maximum of 20 integers values, and fill the array with numbers input from the keyboard or assigned by the program. Then write a function named split() that reads the array and places all zeros or positive...
Hey guys. I just want to see if I am indeed "seeing" the significance of the code that is to follow. I will follow it with a brief explanation of what I thought the code did. Thanks in advance.
const int N = 15;
bool table[N];
int i = 0;
while (i < N)
{
table[i] = true...
Hi,
I'm working my way through the project euler problems in c++ and I've got to one where you have to sum 100 numbers that are each 50 digits long to find the first 10 digits of the sum.
Obviously I could solve it by summing each of the figits in turn then work with them to deal with...
Hey guys, just looking for an explanation for the following algorithm. It is in my textbook, and there isn't really an explanation. I don't really see how the algorithm works, but I will add what I do know, and hopefully one of you can help. Thanks.
//this initial declarations produces an...
Homework Statement
Hello, just having a bit of trouble understanding this bit of code:
typedef int Item;
struct Node {
Item data;
Node* next;
};
typedef Node* NodePtr
NodePtr hdlist = NULL;
Homework Equations
None.
The Attempt at a Solution
I understand that...
Author: Bjarne Stroustrup
Title: The C++ Programming Language
Amazon Link: https://www.amazon.com/dp/0201700735/?tag=pfamazon01-20
Prerequisities:
Contents:
Author: William H. Press, Saul A. Teukolsky, William T. Vetterling, Brian P. Flannery
Title: Numerical Recipes in C++: The Art of Scientific Computing
Amazon Link: https://www.amazon.com/dp/0521431085/?tag=pfamazon01-20
Prerequisities:
Contents:
Hey guys,
I'm having trouble with sampling data from a force/torque sensor. I'm using Serial Com to receive the readings from the sensor, which is stored in a character of with 45 individual elements. What I'm trying to do is to pick out pieces of these data and store them separately. I'm...
Homework Statement
I am writing a program in c++ where it inputs card values from the user and stores it in a char type variable. valid inputs are numbers 1-9, t,k,q,j for ten, kind, queen, jack respectively and a for ace. after inputting all the values the program goes like this
if (!(card1...
Homework Statement
I'm making a program which will convert mph to minutes and seconds per mile. For example my program will take 6.5 mph and convert it to 9 minutes and 13.8 seconds per mile. But being new to programming I don't know how to convert a double value to an int value (I believe its...
Homework Statement
I am making mini programs where there some calculations going on and when all that is done my program is to ask the user if he wants to repeat the calculations or not. If he does then the program is to restart and if he doesn't then he can close the window by pressing the...
I want to output an excel file with the results of the trajectories of a two body problem, with initial position and velocity. But my program is not compiling. Any suggestions/problems that you can see?
#include <iostream>
#include <vector>
#include <fstream>
using namespace std...
Hello,
I was looking at an Introduction to C++ class I might be taking next semester
Description:
This course is an introduction to the basic principles of programming using
C++ as the development tool. Topics include the structure and design of algorithms, input/output,
branching...
Hi, currently i am studying the performance of axial turbocharger, and i have formulate the equation and all the data in Microsoft excel, and i want it to be convert into C++ language, could anyone teach me how to start by doing this, because i am totally new in C++...please...i already upload...
Homework Statement
can some one tell me what I am doing wrong in this program. I am getting a
error C2296: '^' : illegal, left operand has type 'double'
error at line 10 where I do my distance calculations. I am using Microsoft Visual Studios 2008.
Homework Equations
The program...
Homework Statement
Homework Equations
The Attempt at a Solution
#include <iostream>
#include <cstdlib>
using namespace std;
using std::cout;
int main()
{
int sum=0;
int Array[] = {1,2,3,4,42,5,6};
// int Array[] = {42,1,2,3};
// int Array[] = {12,-10,42,10};
// int...
Hello,
I'm new to Microsoft Visual Studio and new to the C++ program. I just installed the program and I'm trying to write my first program.
First error that I get is: ========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
Why is my project out-of-date?
Second...
Homework Statement Hello, the problem is in this video. It is displayed near the end starting from 6:19 onward. It's titled "Extra Credit"
Homework Equations
For Loops
and If Statements?
The Attempt at a Solution
Here is my attempt at the problem:
http://www.getcode.me/3sr0mzy7rz1cgrfu
C++ or verilog or random process ??
I'm currently in 3rd year of my undergrad in Electronics & Communication engg. For my 6th semester, I'm required to take 1 elective from the following-
-Data Structures with C++
-Random Process
-Digital System Design using Verilog
-Analog & Mixed mode VLSI...
HI, i am a student taking final year project in my university, my project title was C++ modelling of axial turbocharger, it was a counter-rotating turbocharger, can anyone help me to get some useful information to complete my project? thanks
I'm into my second year now at uni and after learning Java for the past year, the course is now introducing us to C++. We're still doing java but now C++ aswell.
I don't know if I'm the only one but C++ is sooooo much harder than java, today after just our second lesson we're being introduced...
I am taking C++ this semester, and am not really good at it. It is my first programming class, and I kind of stink, though I am trying. I don't think I'm going to get a great grade, and it will bring down my average. I was thinking of dropping it, but then had a look at the class averages...most...
Hey. I have to create a program in C++ to calculate the number of prime numbers up to a specified number. I also have to print out the first and last 5, but I'll cross that bridge when I come to it.
I can do this fine with integers, but we have to do it where each slot in an array represents...
Hi everyone! My primary question is below the problem.
My problem:
Circles
The standard form of an equation for a circle is (x − h)2 + (y − k)2 = r2 where (h,k) represents the center of the circle and r is the radius. The y-value of the equation becomes zero at the point of intersection with...
I have a new problem where I have 2 formulas, and I need to tell my program that at certain intervals/parameters/bounds it needs to do one of the formulas and at other intervals it needs to do another one.
To be more descriptive When ever my time=0 to time=(T/2) it should do formula 1, and...
#include <iostream>
#include <cstdlib>
#include <cmath>
using std::cout;
using std::endl;
using std::cin;
int main()
{
double h,v,w,z,y;
cout << "Enter the width, W: ";
cin >> w;
if (w<0)
{
cout << "Error: The Width must be strictly positive." << endl;
return EXIT_FAILURE;
}...
Basic C++ Coding?
Assume that name and age have been declared suitably for storing names (like "Abdullah", "Alexandra" and "Zoe") and ages respectively. Write some code that reads in a name and an age and then prints the message "The age of NAME is AGE." where NAME and AGE are replaced by the...
Homework Statement
why the loop not looping ?
Homework Equations
fun1=x^3+4^2-x-1
fun2=3x^2+8x-1
The Attempt at a Solution
#include "stdafx.h"
#include<iostream>
using namespace std;
float fun1(float);
float fun2(float);
void main()
{
float a;
cin>>a;
if (fun2(a)>0)...
Homework Statement
find the roots ( interval halving ) , I want to know how to make a condition statement that when fun3 be less than 0.001 and then loop will stop and i get the root .(here in my code i don't know why the loop doesn't work as it should ..
Homework Equations
the...
I am using a verlet algorithm in c++ to model the motion of a satellite, and want to output position and velocity data from each timestep so that I can then read it into MATLAB and plot graphs to see how well my model matches the 'real life' graphs. so far I have at the end of each iteration...