C++ :: Determination If Sequence Is Increasing Or Non-decreasing?
Dec 6, 2014
Code:
#include <iostream>
using namespace std;
int j;
int n;
int recursive ( int arr[j] );
int main() {
int i;
int arr[10000];
[code]....
This is how I tried making the program..
I want it with a recursive function
I want if the sequence is non decreasing return true else return false
View 10 Replies
ADVERTISEMENT
Mar 25, 2013
Any examples of a c++ program that uses recursion to find the longest increasing sequence from a grid in a file. Like
2 4 6 8
10 12 14 16
18 20 22 24
I have to use a structure named Point and a structure named Sequence.
const int MAXROWS = 4;
const int MAXCOLS = 4;
const int MAXFILENAME = 255;
// Structure used to define a point (x,y) in the grid.
typedef struct {
int x, y;
[Code] .....
View 1 Replies
View Related
Mar 26, 2013
suppose I want to find the value of e ,e^x or sin(x) or any such function in general ,through their infinite series (maclaurin or taylor) how many iteration should I have to make to get the result correct uptu 'n' decimal places?
View 6 Replies
View Related
Feb 17, 2013
Question: What is the efficiency and big O of the selection sort algorithm when the input happens to already be in nondecreasing order?
Answer: Not sure... since the input is in nondecreasing order, such that example 0, 1, 1, 2, 3, 4, 4, 5 then there will be no swap, Just comparisons of emelemts. So it is big O of n
View 2 Replies
View Related
Nov 26, 2014
// my size is not decreasing when I erase a record.
//dvr_hwch.cpp
#include <iostream>
#include <iomanip>
#include <cassert>
using namespace std;
#include "hash_chn.h"
void print_menu( );
[Code] .....
View 1 Replies
View Related
Mar 24, 2013
I am supposed to make a program that take a list of integers from the user and to delete the smallest part of it in order to make it sorted in non decreasing order ..
example : input : 1 2 3 4 5 8 7 6 7 8 9
output : 1 2 3 4 5 6 7 8 9 ( delete : 8 7 )
I need a code that use a technique similar to the merge function to achieve linear time ..
this code works but it is in quadratic time :
int main () {
cout<<"Enter a list of numnbers ending with the sentinel -999:"<<endl;
int A[1000];
int n = 0;
int x;
cin>>x;
while(x!=-999)
[Code] ....
View 4 Replies
View Related
Oct 10, 2014
Im having trouble on getting the quantity up of the variable "item.iqty". For example the current quantity is 5 and in this function, the user inputs a number and it should add to the variable "item.iqty". So if if the user inputs 2 then the current quantity should be 7 now but in my program it hasnt changed. its still 5
void addQty(FILE *fp)
{
int num, qty, r, c, n;
bool found;
[Code]....
View 3 Replies
View Related
Sep 5, 2014
I'm trying to implement a linked list using my own node class. I've created functions to add to the head and tail, return the size of the linked list as well as the value stored within the current pointer.
However, my problem is that when I wrote a test program to see whether my list worked, my list did not appear to increase in size past 1 item in the list.
this is the test program I wrote:
int main() {
int counter,
data;
linkedlist *my_list = new linkedlist();
cout << my_list->size() << endl;
for (counter = 0; counter < 5; counter++) {
[Code] ....
I'm sure it's probably something simple that I've overlooked . But I'm still relatively new to the concept of dynamic memory allocation.
View 2 Replies
View Related
May 2, 2014
class Album{
private:
char albumName[100];
Song* List;
int numSongs;
public:
Album(char*);
~Album();
[Code] ....
And everytime I create the class it can have only one song because I set numSongs to zero.
View 2 Replies
View Related
Jun 1, 2014
I am trying to make a double array, but I keep getting an error Segmentation fault (core dumped) when I make more than 105 elements in the array. I need to make 114 elements.
I am building my array with myarray[999] and increasing the number doesn't seem to do anything.
How can I store more elements in my array?
View 1 Replies
View Related
Nov 15, 2013
I am new to programming all together but i have been writing a program in c++ and im coming up against an issue with my array.
#include<iostream>
#include<iomanip>
#include<string>
using namespace
int main () {
int a ;
int b ;
char answer ('Y') ;
[Code] ....
I am trying to get the program to increase say year one by 1 when the condition is met i have tried
if ( a >= 70 && a <= 100 && b == 1)
{grade [0][0] = 0 + 1;}
and
for (grade[0][0] = 0 ; a >= 70 && a <= 100 && b == 1 ; grade [0][0]++)
{grade [0][0]= 0 + 1 ;}
Now all that i want is that the array will take the information from int a and int b and then add 1 to the appropriate part of the array . I have tried putting it in deferent places but its not working for ether. the program will run but it will not add to the array.
View 13 Replies
View Related
Apr 23, 2012
We have socket server which is developed in c# .net 3.5.
I see server memory keep on increasing whenver client disconnectes and connects.The server disconnects client if client didn;t send valid credentials.
When client is trying to connect with invalid credentials the memory is keep on increasing.
Here is the code that handles disconnection.
try {
if (state.workSocket != null) {
log.DebugFormat("ssl socket displose,{0},{1}", Doomed, IP);
state.workSocket.Shutdown(SocketShutdown.Both);
state.workSocket.Close(1);
state.workSocket = null;
log.DebugFormat("ssl socket displose complete,{0},{1}", Doomed, IP);
[Code] ....
View 7 Replies
View Related
Sep 12, 2013
All I have so far is a rectangle that prints 5 stars in length and 20 lines in length. What I want to do now is have each new line print an extra space more than the line before it and then print 5 stars.. This is what I have so far:
Code:
#include <stdio.h>
int main (void){
int i;
for(i=1; i<=20; i++){
printf("*****
");
[code]....
View 1 Replies
View Related
Jan 14, 2014
unsigned char x1, x2, x3;
size_t ix = 0;
size_t count;
std::string Input = "EFEF9E9475C8C2D938C204EAE058F2B3";
[code]....
when debug and have a watch on out i get incomplete sequence,
View 8 Replies
View Related
Mar 6, 2013
Code:
int main()
{
int n;
int* fib;
printf("
Fibonacci test 1: enter an integer
");
scanf("%d",&n);
fib = fibonacci(n);
printf("fib(%d) = ", n);
for(int i = 0; i < n; ++i){
printf("%d ", fib[i]);
}
What should I do/write for the fibonnaci function Code: int fibonnaci(int size)
View 7 Replies
View Related
Sep 2, 2014
I made a fibonacci series with label above it now how to put the label after the first layer because as you can see in the screenshot the label is continuous.
View 2 Replies
View Related
May 20, 2013
Why is it that in the STL it is standard to indicate a sequence of elements in a container by a begin iterator that points to the first element and an end iterator that points to one past the last element?
View 2 Replies
View Related
Aug 22, 2013
My assignment is to write a program that reads in a number from the user and then generates the hailstone sequence from that point. I'm not sure if I should use an if statement or string loop. The beginning of an attempt
#include <iostream>
#include <vector>
#include <string>
using namespace std;
vector<string> Numbers;
/// if n is equal to 1 the sequence has ended
/// if n is even divide the number by 2
/// if n is odd, multiply by 3 and add 1 to new number
[Code] ....
View 2 Replies
View Related
Sep 16, 2013
I have to write a program to find the nth number of the Ulam numbers.
It's a bit complicated to explain what an Ulam number is but Wolfram explains it very well here: [URL]
I have to find the nth Ulam number but I don't know what I have to do to get that. My program gives me all the Ulam numbers from a range of 0 to n.
What I want the program to do is tell me that the 49th Ulam number is 243.
/*
C++ Program to find nth Ulam Number
*/
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int num = 0;
vector<int> v;
[code]....
View 4 Replies
View Related
Oct 6, 2014
I made a program that prints out arithmetic sequence.. but problem is that,
when I enter a(first term) =5, d(differnce)=2.4 and n=3 the program prints out only first two terms not three.. for all the other numbers it works correctly..
View 1 Replies
View Related
Apr 24, 2013
I am trying to write a program that checks whether the number is in sequence(as in if the numbers are in order it is a sequence). Ex: If the numbers are {1,2,3,6,7,8,9,10,11,13,15,17,20,21}, then, the underlined parts are a sequence. Now i want to find
1) the no of sequence in the array(in the above it is 3 )
2) the longest sequence (7to 11 which is 5).
View 2 Replies
View Related
May 5, 2014
Q) How to do nested loops?
Q) How to do Array?
Q) How to do Fibonacci sequence?
View 1 Replies
View Related
Feb 16, 2014
The next code is right. I mean it works. It gives the sequence of fibonaci numbers ...
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int fibo(int pos) {
if(!pos)return 0;
if(pos==1)return 1;
[Code] .....
But.... when I change the lines:
Code:
int r1=fibo(pos1);
int r2=fibo(pos2);
int r=r1+r2;
For the lines:
Code:
int r=fibo(pos1)+fibo(pos2);
It doesn't work right. Apparently it should work the same.
View 11 Replies
View Related
Feb 2, 2013
I'm doing some file input/output work here in C and received this warning during compilation (GCC). My research indicates that this error is in response to white space or a character cancellation function or something like that. I'm not 100% sure exactly what it means. My code works fine, but the following warning does appear.
Code:
warning: unknown escape sequence: '40'
Here's my code (excluding a bunch of comments at the bottom of the file).
Code:
#include <stdio.h>
int main(void){
FILE *file;
file = fopen("Running Practice.c", "a");
fprintf(file, "Testing...
");
fclose(file);
}
I believe the error I received has to do with either the ' ' I used when appending text to my file, or something to do with there being a space in the file name itself.
View 6 Replies
View Related
Nov 18, 2014
I'm saving the images in folder by using:
webClient.DownloadFile(href, sourcepath);
I don't want to give name as Current date and time..shown in given below code
string sub = @"Gadhada";
DirectoryInfo subFolder = dir1.CreateSubdirectory(sub);
Imagename = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() +
[Code].....
I want to save my imagename as 1.jpg, 2.jpg, 3.jpg.
View 1 Replies
View Related
Nov 4, 2014
A sequence point in a C program is defined as "Any point in a program's execution at which it is gauranteed that all side effects of previous evaluations will have been performed and no side effects from subsequent evaluations have yet been performed."
What is a side effect?
View 7 Replies
View Related