I need to add thevArr[I] and vArr1[I] and store in vArr2[I] but I cant figure out how to drop the value or replace with a 0 if vArr is bigger than vArr1. IE: 1st number: 123 2nd number: 4567
Ill get something like this:
1 2 3
4 5 6 7
5 7 9 -827349
I'm building a box to take in several arrays of different lengths. one group happens every 10 seconds. one of them happens every 5 seconds. this is from a weather station.
I plan to retransmit them, substantially unchanged at a lesser rate to save radio power over a serial data link. buried in groupD, I want to change a few chars before retransmit.
I don't want to go to the trouble of doing a structure for each of them since most will be resent unchanged. some entries are chars, some are decimal, some are a mix. I guess it might be convenient to further define groupD, maybe not.
what is the best way to declare the group? I want them to be contiguous since that's how they will end up in the tx buffer. Each subgroup has its own checksum, so I planned it this way to make checksum more convenient.
I am using 2 ARRAYS OF DIFFERENT SIZES in One 2-Dimensional Vector, and my output is not correct. The arrays are size 4 and size 13.
I want COLUMN 0 to have: 55, 66, 77, 88.
I want COLUMNs 1-12 to have 1,2,3,4,5,6,7,8,9,10,10,10,11 in EACH ROW. It would seem that the 2nd loop for the size 13 array would need to loop 4 times in order to fill 4 rows, however, I'm not sure how to do that. Here is what I have so far in code and output:
#include <iostream> #include <vector> using namespace std; int main() { int typeArray[4] = {55,66,77,88}; int valArray[13] = {1,2,3,4,5,6,7,8,9,10,10,10,11};
I'm working on a homework assignment that asks me to roll two die a user given number of times, find the roll sums, and a few other things. I'm working on it one module at a time and I'm running into two big problems so far.
The first problem is that my int variable rolls changes to a number within the random number generator range of numbers after I run rolldie. I got around this by making a const equal to the user entered value of rolls just so that I could continue developing the program.
My second problem is that the values of the arrays resultsOne[] and resultsTwo[] are changed after running findsum(). Why this is happening and I even tried passing them as const, but that changed nothing. We just started learning about passing arrays to functions, so there might be something big that I'm missing.
Code: #include <iostream> #include <cstdlib> using namespace std; void rolldie(int resultsOne[], int sizeOfresultsOne, int resultsTwo[], int sizeOfresultsTwo); void findsum(int resultsOne[], int sizeOfresultsOne, int resultsTwo[], int sizeOfresultsTwo, int tossSums[], int sizeOftossSums);
I need to input values for two arrays and then add the two with all of it being print visible. I have this so far but can not figure out how to add the two arrays.
#include <iostream> using namespace std; int main () { { int const ROWS = 3; int const COLUMNS = 3; int square[ROWS][COLUMNS];
You will have two file streams: an input file stream for the file to be normalized and an output file stream that contains the normalized file. You should issue an error message and exit the program if either file cannot be opened. Your program should prompt the user for the filename of the file to be normalized (the input file). The output filename should be the input filename with ".normal" added to it. For example, if the input file is "data.txt", the output file name will be "data.txt.normal".
Be careful to not leave an extra blank line at the end of your output file.
My question here is how do I rename the file that the user entered to have a ".normal" at the end of it? I was thinking along the lines of having to string names and changing the second string's name and use that as the output file. any examples cause I didn't exactly get that to work.
I'd like to start out by adding an array to a C++ class. I'd like to be able to reference the array using a class object that I create, for example:
Class is Stone.
Stone Bob is an instance of "stone" that I name "Bob".
"Bob.array[1] = "granite";" tells the compiler that the second element in the array (with the first being the zeroth element) is a string containing "granite".
I'll eventually want to extend this to an n x m matrix within the "stone" class that can be referenced as: Bob.matrix[1][3]="lignite";
I tried to make this work using a text again and again last night to no avail. My code is below.
NOTE: Since I am dynamically allocating memory space, I'd like to avoid memory leaks when using this class with dynamically allocated arrays and matrices. Not sure how to do this. Also need some insight into "destructor", and why my simple version reduced to a comment below doesn't seem to please the compiler.
CODE FOLLOWS:
Code: // AINOW.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <string> using std:: string; using std:: cout; using std:: endl; using std:: cin;
I am currently working on a program that uses a class to store integer arrays. I have most of the code done, but I am having trouble on the main.cpp part of my program. The program should display this:
I'm writing a program with two classes, one that contains a card's rank and suit and the other contains pile of these cards. I'm having trouble when it comes to adding a pile to another pile...here's what I have so far:
class Card //Card class declaration { private: int rank; //invoking rank char suit; //invoking suit public: void setCard(int r,char s); //determines card suit/rank
[Code] ....
I understand that I'm calling my pile arrays incorrectly, but I'm not sure why.
I create new dialog window. I add container Fixes and change Fixed properties : - AutoSize, +Expand, +Fill to enable other widgets. I add Text View, Textview is inside GtkScrolledWindow which has property X and Y but not Height and Width. If GtkScrolledWindow has scrollbars, its size is fixed, if not - size depends on the content Textview and grows when I type text. I want not to grow control if I type Text but want my own size. It is possible?
I'm trying to find the MAX and MIN integer sizes that are entered in by the users. I know that we need to sort [i] and [j] in my function to figure out which is the highest and lowest score correct?
#include <iostream> using std::cin; using std::cout; using std::endl;
I have a paradigm where a integer before gets enqueued to a queue in a vector, the loop of queues is searched and integer is enqueued to a queue which has minimum size among the queues. the following code shows the operation
next i am trying to extend my paradigm with the condition, that the integers should be enqueued to the shortest queue until the count of the shortest queue is less than or equal to count of any another queues in the loop of queues.
The size of fundamental types is not guaranteed. Apparently, all the standard guarantees is a hierarchy of sizes, and some minimum representable value range.
Specifically, a char is not guaranteed to be one byte. Also, the sizeof operator always returns 1 for the size of a char, even if the actual size is not eight bits.
Isn't this a huge problem for portability? It seems like 2+ byte characters would break all kinds of things. For example, fstream::write() takes a char * and a byte-length argument. If you ported from a 1-byte-char platform to a 2-byte platform, wouldn't that screw up all your write()s? Worse, you couldn't even detect the problem without trial and error, since sizeof would just lie to you.
I've never actually seen a platform where char wasn't 1 byte, but it sounds like a disaster waiting to happen.
I'm writing a program where I need to generate a conversion table for wrench sizes with the following columns: Size (Inches) [Fraction], Size (Inches) [Decimal rounded to 3], Next Bigger Metric (mm), Difference (Inches) [Next Bigger Metric-Inches], Closest Metric (mm) [to original size], and Difference (Inches) [Closest Metric-Inches]. I've created the column for the Size in fraction form relatively quickly but I cant seem to produce the decimal version. Instead, I get 0.000.
I have an advanced data namespace in which I hope to be able to read a data variable of any type and transfer it's bytes into another type of a multiple size.
i.e. char[4] -> int; int -> short[2]; short -> char[2]; char[2] -> short;
but I'm having some trouble, I get the following errors (because as a template it must compile from start)
I have a paradigm in a loop of queues of a vector,if a condition is true,increase sizes of the queue of that particular queue in the loop of queues, if condition is false, the queuesize is left as such in loop of queues. After this operation i need to search the queue sizes of all queues and enqueue in the shortest queue.
I define "Comwords" as a string, but apparently it takes the members as chars, then I can't set strings in a structure equal to the chars.
I see to also be having unknown problems with the ComMAL array and loading it values into another element of the same structure.
How to correct this? I was thinking of casting char elements as strings, but could find no reference in my library book regarding how to do that (lots on casting int's a doubles...)
Code:
int _tmain(int argc, _TCHAR* argv[]) { int comm = 10; int targ = 5; int death; struct AI_WORDS
Using a for loop, construct two 100 element arrays, x and y, such that element i of x stores the value sin(2*pi*i/100)) and the corresponding element of y stores cos((2*pi*i/100)). Print the values stored in the elements of x and y as you calculate them.
I have attempted to solve it but I'm not sure why the value 0 is only being printed, maybe I haven't assigned sin(2i/100)) and cos((2i/100)) to the arrays properly?
Code: #include<stdio.h> #include<stdlib.h> #include<math.h> int main () {
I'm trying to write a function that takes a 32bit address and a data to store at this address.
I'm wanting to take the 32 bit memory address eg 0x12345678 and split it into 4 x 2 bytes 12, 34, 56, 78
then each of the 4 entries is at most a 256 entry array.eg FF, FF, FF, FF
So in this example, 0x12 points to 0x34 in the second array, which points to 0x56 in the third array, which finally points to 0x78 in the last array. This last array holds the actual data.
After successfully doing 0x12345678, say I might get a read for 0x1234AABB. So, the first and second pointers already exist, but I then have to create and write to dynamically created arrays.
The arrays need to have all entries set to NULL so that i know whether to follow the pointers to overwrite a previously entered value or create new arrays and pointers.
It all looks good and simple in the pseudo code I've written up but I'm having trouble coding it. I'm currently trying to deal with the first entry case, ie all array elements are NULL, but I'm getting confused with the pointers and creation of new arrays.
void cpu::store(unsigned int mem_add,unsigned int mem_val) { int first = (mem_address&4278190080)>>24; int second = (mem_address&16711680)>>16; int third = (mem_address&65280)>>8; int fourth= (mem_address&255);
Every time I run if(color=="1") it's supposed to add 1 to redTotal. However, every time I run if(color=="1") if get 1 for redTotal every time.
(Write a program that provides the option of tallying up the results of a poll with 3 possible values. The first input to the program is the poll question; the next three inputs are the possible answers. The first answer is indicated by 1, the second by 2, the third by 3. The answers are tallied until a 0 is entered. The program should then show the results of the poll—try making a bar graph that shows the results properly scaled to fit on your screen no matter how many results were entered.)
Code: #include <iostream> #include <string> using namespace std; int main()
I am new to c and I have come across a problem when adding other functions to a programme and printing the values. The question I am attempting to solve is :
The following function computes ex by summing the Taylor series expansion to n terms. Write a program to print a table of ex using both this function and the exp() function from the math.h library, for x = 0 to 1 in steps of 0.1. The program should ask the user what value of n to use.
double taylor(double x, int n) { int i; double sum = 1.0; double term = 1.0; for (i=1; i<=n; i++) { /*Or we could have written: */ term = term * x / i; /* term *= x / i; */ sum = sum + term; /* sum += term; */ } return sum; }
My code is
Code:
#include<stdio.h> #include<stdlib.h> #include<math.h> /*Taylor series for e*/
[code]....
code prints out the values for exp, but it gets stuck in the Taylor function and I'm not sure how to solve it.