Homework Statement
Working on a program that will calculate the results of a shootout between 3 people, each of whom have a different level of accuracy (one hits his mark 1/3 of the time, one hits his mark 1/2 of the time, one hits his mark 1/1 of the time).
Homework Equations...
I am trying to read from a csv file, the file looks like below:
1,2,3
4,5,6
7,8,9
0
I used getline(Input_file,size,',') but the problem with this is that it seems to see the numbers not separated by commas as one string., for the code below i was expecting the following output:
1...
It's been years since I last programmed in C++ and I want to brush up on it over the next couple weeks. Problem is I have no idea what's out there that I could use for programming/debugging C++ programs; the compiler I used before came on a CD with the textbook, but now I'm completely on my own...
Homework Statement
I am solving a problem in which I am reading numbers from cells in a csv file, I used getline to get strings from the csv file then converted the string to an integer... but the getline seemingly discards the last cell in the csv file
Homework Equations
this my C++...
Hi all,
In the book "Financial Applications Using Excel add-in Development in C/C++" 2nd edition by Steve Dalton in Section 3.7.2 Passing arrays and ranges from Excel to VBA to C/C++ and in that section a description of how this can be done is given. No example of how to do this is given and...
Hi all,
I'm a programming newbie teaching myself C++ mainly for interest/ because I might want a real job after my physics PhD, but I have a problem in my research some code might be useful for.
I have some functions defined by integrals of the form
$$A(q)=\int db~ b* J_{0}(b*q)...
Hi all;
I'm a physicist _High Energy Physics Major_ and i use some computer software that is based on C++ Programming Langauge such as (ROOT data analysis frame work - Pythia event generator)
and i need a reference or textbook that learns me C++ effectively, i have some choices:
1)Object...
Hi everyone, I am new here, nice to meet you.
For fun I am trying to make a gravity simulator in c++ and using SDL.
I believe there is a problem in my merge function when I calculate the new velocity and trajectory of two colliding bodies.
Also, does my main code look accurate. The part...
My problem is not so much with programming it, but rather determining which side is collided.
And for those who aren't familiar with SDL, SDL_Rect is just a structure that hold an x and y
position along with a width and height ( (x,y) is the top left corner of the rectangle).
So here is how...
i made a c++ login program but There is Problem occurred During Compairing a Given user name (string ) with a Pre defined String. Please give me some solution of it.
program
#include<iostream.h>
#include<conio.h>
#include<string.h>
class converter
{
public:
double i,j;
char m...
I'm making a 3D rotation of a poligon.The problem is when I rotate some points in 2D, it works, but if I use the same function to rotate the same points in a 3D perspective , while rotating the vertices move to the center of the object and remain there.
I also wrote the 3D rendering part.At...
Hi all,
I'm using Fedora 16 and installed Octave thru Yum.
There is an example in the Octave manual of using Octave with C++ and it #includes a oct.h file.
However, the Fedora build may not have compiled the oct.h library ? or I'm searching in the wrong places.
Has anyone had any...
Hi,
For example, say we have the binary integer 101010 and I split it into blocks, say (1)(01)(01)(0). The size of the blocks is determined by some function. We want to count the number of '1' bits inside each of these blocks.
I'm interested in a fast C++ code to do this. There are fast...
Hey gang,
I'm trying to use MPIBcast to distribute a user entered value across all nodes, but it seems like only the root node is working (i.e. no broadcast).
I'm using OpenMPI 1.5.4 with the following code:
A=0;
std::clock_t start;
double duration;
start = std::clock()...
Maybe this should belong in the logic section. But since this is C++, ill put it here.
bool isLeapYear( int y)
{
return y%4==0 && y % 100 !=0 || y% 400==0 ;
}
They said it returns when y is divisible by 4 but not by 100 unless it is also divisible by 400.
This is a bit...
Hello everybody!
Here I wrote simple code for power of n number. At result I need to get an integer value. But my code works only small number of power. (Here in my code is p: 10^p). If I increase p number, then the result will be like this: 2.74*10^6=2.7e+006. But I need the result will be...
This little test of templates and non-member functions works fine:
// test5.cpp : main project file.
#include "stdafx.h"
using namespace System;
template <class T> void mytest(void);
int main(array<System::String ^> ^args)
{
mytest<double>();
mytest<int>()...
Homework Statement
Well I have written my entire program for my assignment, but I cannot get it to compile without multiple instances of the same error: "expected primary-expression before ']' token. Can anybody see a mistake I am making? I would greatly appreciate your help, thank you...
Hello, I'm trying to make part of a code that reads a csv file with data containing the date and time, and the wind speed at that time, then does various output things.
When I copy and paste 1000 entriesinto a csv file and ru it, it works great, but if I use the file that's about 6,000kb it...
Homework Statement
I am trying to rotate a 2D array of type string. I am not sure what the problem is with my function. Flipping does occur but for some reason, it's not by 90.
Homework Equations
The Attempt at a Solution
The program consists of a function and the main. Here's...
Homework Statement
I am attempting to transfer the data from a file into a 2D vector array. The data look like this:
1 2 3
4 5 6
7 8 9
However, the dimensions must be detected dynamically.
Homework Equations
The Attempt at a Solution
There are two files in this code, but I attempted to...
Homework Statement
I'm starting my C++ project which requires me to call a file stream and output the data to four other output streams.
Before I start, I want to know if I need to have a .dat file premade and saved somewhere so I can call it or do I just make that file in my code by using...
#include <iostream>
using namespace std;
int a;
int main()
{
cin >> a;
int c [a];
for (int i = 1;i!=a+1;i++)
{
c [i] = i;
}
for (int i = 1;i!=a+1;i++)
{
cout << c [i] << endl;
}
return 0;
}
This compiles and does exactly what it's supposed to. But wait...
As a basic exercise in C++ functional programming, I wrote the following code:
#include <iostream>
#include <string>
using namespace std;
template <class T>
void Wib (T& a,T& b)
{
T temp = a;
a = b;
b = temp;
};
int main()
{
string A = "World!";
string B = "Hello, ";
Wib <string>...
Alright. I know how incredibly inefficient this algorithm is, but I felt like giving this a whirl.
#include <iostream>
#include <cmath>
using namespace std;
bool prime(int x)
{
bool j = true;
for (double i = 2;i == x;i++)
{
if (x/i == floor(x/i))
{
j = false;
}
}
return j;
}...
I'm interested in a lot of science involving ODEs, PDEs, and discrete functions of up to 4 dimensions (one of time). Can anyone suggest a library that would be capable of plotting even a subset of that?
Homework Statement
My printArray function, when called in my int main() with the arguments ("***monthly total***, sums, NUM_MON) is printing out twice as many times as it should be, and for some reason, even the string caption is printing out as "******monthly total******" instead of...
Homework Statement
I am not completely finished with the assignment, but I was trying to test to make sure that my functions "low" and "high" would in fact return the proper value (the lowest number in the array, and the highest number in the array, respectively). However, when I compile, I...
Homework Statement
I came across some codes that calculate the smaller string using user-defined functions.
I tried figuring them out, but some parts I don't get. This is the first one:
bool isShorter (string& s1, string& s2) { // the string objects may be large!
return...
This program has been assigned in my intro to programming course, which assumes no previous knowledge of programming. Up to this point we've only been required to write functions that accomplish specific tasks within a program. This is the first time we've been asked to design and write a full...
Hi,
If I have a method that takes in say 5 new variables and assigns 5 class variables to these new values, and I only wanted to change one of these variables, is it possible to reuse this method and only have it take in say 1 new variable and change one class variable without having to write...
I am an electrical engineer who does quite some engineering math in my work. I also need to use computers quite a bit, but ALWAYS find the entire culture of unix and C/Fortran coding intimidating. Here is an example:
I tried to compile my "hello.cc", I typed "gcc hello.cc" and got "a.out". I...
Hello all,
I am looking for an excellent book on C++ programming to read during the summer. I have never programmed before, so it would most definitely have to be at the calliber of a beginner. I'm looking for a book that begins with basics such as algorithms, pseucode and then the actual...
Homework Statement
Create a function called isEqual(). isEqual() takes two strings and determines if the strings are identical. isEqual (s1, s2) should be the same as s1 = = s2
#include "stdafx.h"
#include <iostream>
using namespace std;
bool isEqual(int *s, int *st, int x);
int...
Hi, noob question here,
In C++, how can I return boolean comparison between two object pointers?
ie. return True if the pointers point to same object.
I've tried == but it doesn't work.
Do I need to define a comparison method from within the class?
If so what is the syntax for doing it?
Thanks.
Homework Statement
Im taking my first physics class and We have to do a research project. The project can be anything we want. I decided to make a c++ program to model a charged particle in a magnetic field. When I first researched the problem I't seemed straight forward enough. The force on a...
Homework Statement
I am writing a program which requires me to make and call a function: string Menu()
This function will display a message to the user. It will then accept the user's choice (as a string) and check it for validity - that is did the user enter a "1", "2", "3", "4", "Q", or...
Does anyone know of any good texts that are geared towards creating Physics Engines using c++? Or at the least, a text on creating physics engines in general? Any personal recommendations would be great.
Hi everyone!
I am a mobile robot designer in autonomous space robotics. there is a great dilemma in front of me to opt a programming language for the robots between C++ and Java.
the most important factor for me is performance of the language when i want to use it for applying very...
Heres my problem, step one I've solved. Step two only ever returns the original newRoot*newRoo and I don't understand how to correct itTo demonstrate event controlled loops use arithmetic to create:
1.Create a sequence to determine the next largest perfect square
2.Create another sequence to...
Having a lot of trouble the my C++ course, loops especially. This is the assignment giving me trouble
The function you are to implement finds a root of the given function eff(x) using Newton's method. The given version of eff(x) implements f(x) = x2e-x-2 (where e is the base of the natual...
Hello everyone. I have an assignment that is asking me to find the roots using the bisection method. We are to find roots for two different functions.
f(x) = x3 + 3x - 1
and
g(x) = x3 - 2sin(x)
I was wondering if there is any way to assign these functions to the variables f and g...
Homework Statement
I am in a beginner c++ class and this is my second program. I am having trouble getting the calculations to output correctly. I'm not sure what I'm doing wrong here, maybe somebody can help.
Homework Equations
The program takes user input data for points in a...
I had a homework assignment that wanted me to write a function that would determine whether a five digit integer was a palindrome or not
When I run the program I enter the palindrome there is no output for my if/else statement. What did I do wrong? Code Below
#include <iostream>
using...
So I want to learn C++ & website making as a side hobby since I have some free time in my days. What programs do you all use and would suggest for C++, Visual C++ ? LOL.
And for website design or making; what program? Sorry I don't know the correct terms.
Hi,
I need to implement polynoms in c++.
I thought of doing this with lined list,i am not alowed using c++ linked list, so i will built it myself.
I started thinking of adding and substructing,
should i first sort the polynoms i want to sum by its exponents? (in this case it will be easerear...
learning C++ by reading the code of open source projects?
Is there any resource that teaches C++ by taking an open source project (at the level of quake 3 for example)and explains the code step by step for some one who only knows the very basics . In my opinion It will be very efficient . I can...