C++ :: Simulate Quantum Tunneling Current - Code Doesn't Do Calculation
Mar 6, 2014
Overview: I'm creating a code to simulate quantum tunneling current.
I'm getting the code to output data on a spreadsheet file, and it all works except the following part, which are just giving values of 0 all the way down for the entire column.
j_tl=((eV*hbar*k)/(m/c*c))*(1 - R_lr - T_rl);
When I remove the ((eV*hbar*k)/(m/c*c)) part of it, it gives out values for the (1 - R_lr - T_rl) so I presume the problem is in the former. But I'm struggling to think what it could be. The same is happening for j_tr.
Full code here
#include <iostream>
#include <math.h>
#include <fstream>
#include <stdio.h>
using namespace std;
int main() {
double k,q,p,y;
double E; //Electron energy (V)
I've implemented it a bit differently: I create 2 temporary arrays, one for the numbers lower from the pivot , an done for numbers greater then the pivot. in the end of each iteration the 2 arrays are copied to the original array:
Code: #include <iostream> void QuickSort (int* A , int start, int end){ if (end-start<3){ return; } int mid=(start+end)/2; int pivot=A[mid]; int lA[end-start] , rA[end-start], rCounter=0,lCounter=0; int curr=0,i=start;
Ive been having a hard time creating bin file. Whenever I append data, the data wont show in browse function. And this program works good without the bin file code.
My coin/money change code works when there can be an exact change each time, i.e. when the 1 cent option is available. However, when the change options are only $10, $5, $1, 25 cents and 10 cents, it does not give me what I want for instance, I wanted to get change for $237.80, I was expecting to get:
23 10's, one 5, two 1's and 8 dimes. However, the code below is giving me 23 10's, one 5, two 1's and 3 quarters (there is no option left for the 5 remaining cents).how to fix it?
Code: #include<iostream> #include<algorithm> #include<vector> using namespace std; void change(double cents, int a[]); int main() { double Dollars; double cents;
My task I am trying to accomplish is write a program for C++ that numerically solves a quantum harmonic oscillator. I have a routine that I am trying to implement into this program that iterates through a matrix and finds it eigenvalues, however, I do not know how to put it all together to make it work. Code is below:
Code: //Compiler flags and numerical constants #include <iostream> #include <math.h> #define L 10.0 #define N 200 using namespace std;
have udp server-client application written in C. On the client side packet loss is detected using recvfrom function and sequence numbers of packets. How can I now simulate dropped packet's on the client side, for example if server is sending 1000 packet I want to drop 20% of them? I want to do this in the code, not for example using ip tables or WANEM or something like that. And one more thing, I have few clients and I want that they can dropped different packets, not the same one.
Code: while(1){ nbytes = recvfrom(socket, buffer, MAX_SIZE, 0, (struct sockaddr *) &srv_addr, &addrlen); if (nbytes != -1) { // packet is received
I am writing a piece of code that simulates a random walk in 2 dimensions (an object chooses whether to move up, down, left or right randomly). I would like the program to run the simulation for many objects at the same time. The way i have written it means that for every object i add the code becomes about 40 lines longer. Any method that would simplify the code so that i could have many objects but not pages and pages of code.
Write a program that simulates coin tossing. For each toss of the coin, the program should print Heads or Tails. Let the program toss the coin 100 times and count the number of times each side of the coin appears. Print the results. The program should call a separate function flip that takes no arguments and returns 0 for tails and 1 for heads. [Note: If the program realistically simulates the coin tossing, then each side of the coin should appear approximately half the time.]
I want to write a c++ code that due the structure of file space allocation,Simulates file system with 2*n array. Each column represents a sector. The first row is for storing files And second row holds the address of the next sector (Number of columns). And With each click on keyboard Create a file with random size and automatically find Appropriate sectors by using disk allocation method (or index allocation)... Also File names should be asked from user... And we should have file table Where the starting address of each sector,file extension and file size is given..
So this code compiles without any problem but it is not producing the correct output. I know there's a problem in either my getBlock or putBlock functions but I can't see it.
Currently the output is "Should be 32 1s: " "Should be 32 2s: "
There should be 32 1s and 32 2s and nothing is coming out.
#include <iostream> #include <fstream> using namespace std; class Sdisk { public : Sdisk(string diskname);
How to get live streaming of stock data from yahoo finance? Using C++. I need the code and fetch the data so I can do calculations on the price and volume or what not.
I am trying to simulate memory in C. I want to create a structure in C that will hold a 8bit opcode and a 32bit memory address. This would simulate a 40 bit instruction for my simulator.
I read in an old book that packed structs could be used for this to not waste space. What are the draw backs for using this? I am not worried about wasting space, but just looking for a simple way to access the memory instructions. Below is a sample of the structure that I want to use.
struct memory_area { unsigned int opcode:8; unsigned int address:32; };
I am trying to make a random number generator to simulate a critical hit if the number generated is from 0-critical amount. However, every time i run the code, despite being within the parameters set by the if statements, it always runs through as a critical hit and never a regular hit.
#include <iostream> #include <iomanip> #include <ctime> #include <cstdlib> using namespace std; int main(){ srand((unsigned)time(0));
[Code]...
There are four attempts to save time in getting a good result.
Write a program that simulates an adding machine. When a zero is entered it should print the subtotal of all the numbers entered from the last zero that was entered and reset the subtotal. When two consecutive zeroes are entered it should print the total (not the subtotal) of all the numbers entered and terminate the program. Example:
Be careful this program needs a bit more thought than you might think at first. To get full credit you must make sure it also works for the 0 - 0 case. Example:
0 subtotal 0 0 total 0
The problem is, after I enter the integers and type 0, it shows the subtotal which is what I want; however, when I type more integers and type another 0 to see the subtotal again, it shows the total instead. The subtotal should reset whenever a single 0 is typed and the total should only show when two 0's are inputted simultaneously. Also, after the user enters two 0's simultaneously and views their total, I want the program to exit by saying "press any key to exit." Is there a special name for that to happen? Here is my code:
#include "stdafx.h" #include <iostream> using namespace std; int main() { int subtotal = 0, total = 0, number = 0; bool input_zero = false;
I am supposed to create a program that simulates a random walk that starts with position 0. If its odd it moves to the right (add one) if the random number is even it moves to the left (subtract 1).
#include<iostream> #include<iomanip> using namespace std; void main() { int num1, num2, num3, num4, i, rs = 12345 ; cout << " Please enter the number iterations to be executed: ";
[Code] ....
I'm getting an error when I try to run the program: error C2106: '=' : left operand must be l-value. So I don't even know if what I have is right.
I am trying to make a text editor in C++ that uses Linked Lists as the main driving force. I need to make a program that can add a line of text at a certain point, delete a certain line of text, print the entire text, and quit and save the text to the original text file inputted from the shell script. My problems are with the cpp file, and the linked list files. My remove function is not what I need it to be I know that. I also know that there are some problems with my cpp file myEditor. My code is below.
#include <sstream> #include "linkylist.h" #include <iostream> #include <fstream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char *argv[]) { //node* head = new node;
Create a line class using a linked list that acts as a queue (first in, first out) both enqueue and dequeue. Complete the line class so that customers can be added or removed from the line. Implement the line as a linked list of customer objects that you have developed yourself or use the vector class.
I have not been using pointers that long i most of my stuff has not needed them but now they do i need to learn how to use them more. I'm writing a program that simulates the squares most landed on(for fun) and i cant get a method to work because of an array pointer.
The error is no matching function for call to 'GameLoop::Loop(int, int (*)[4])'
Here is the latest version of the code. I've been editing a lot of things so there might be some stupid errors but I've tring everything.
rolling.h and rolling.cpp are just some dice function they are working perfect.
main.cpp
#include <iostream> #include "Rolling.h" #include "GameLoop.h" Rolling Roll; GameLoop Game;
Write a program to simulate a deck of 52 playing cards.
Represent your deck as a 2D Array where the value in the cell is the position of the card in the deck. Represent the names for the suits and faces as an array of Strings.
Write an algorithm to shuffle the deck.
Display the deck. For Example:
1 Jack of Spades 2 Deuce of Diamonds 3 Three of Diamonds 4 King of Spades 5 Eight of Clubs 6 King of Diamonds 7 Six of Clubs 8 Six of Spades 9 Eight of Hearts
Deal two hands of five cards each. For Example:
****** HAND 1 ****** Jack of Spades Three of Diamonds Eight of Clubs Six of Clubs Eight of Hearts ...
Below is what I have so far. Dealing two hands and displaying it. How would I be able to do that?
#include <iostream> #include <ctime> #include <string> using namespace std; void shuffle(int[][2]); int main() { int j,deck[52][2];
The problem: I am trying to connect the 1d arrays to the 2d arrays. Right now when I write: cout << deck[3][5] << endl; The output answer is 45. How do I populate the 2d array with the 1d arrays so that when I cout deck[3][5] I get it to say "Six of Spades"?