Annadurai
Hi
Tangent Alpha
im currently studying discrete mathematics
me too, needs too much effort
Maanik
Hi I am beginner
Maanik
I starts learning C language
Anonymous
Ok
Maanik
So if I face any problem then can u help me?
Talula
So if I face any problem then can u help me?
Not with your home works... but yes.
⟪ Ⓩub-Er ⟫
#include <stdio.h> #include <stdlib.h> int main () ( int array1 [10], array2 [10], total [20] = {0}; int i; for (i = 0; i <10; i ++) ( arr1 [i] = rand () 99% + 1; string2 [i] = rand () 99% + 1; } int state = 1; int x = 0; while (x <10) ( for (i = 2; i <array1 [x]; i ++) ( if (array1 [x]% i == 0) ( state = 0; break; } } if (status) { sum [x] = array1 [x]; } x ++; } int j = 0; while (x <20) ( for (i = 2; i <array2 [j]; i ++) { if (array2 [j]% i == 0) { state = 0; break; } } if (status) { sum [x] = string2 [j]; } x ++; j ++; } for (i = 0; i <10; i ++) ( printf ("array1% d. number% d \ n", i, array1 [i]); printf ("array2% d. number% d \ n", i, array2 [i]); } for (i = 0; i <20; i ++) ( printf ("% d \ n", sum [i]); } }
⟪ Ⓩub-Er ⟫
Can anyone fix it?
⟪ Ⓩub-Er ⟫
Two one-dimensional arrays of different lengths are undefined. Arrays must be at least 50 in size. Assign these strings 2-99 adventurous values. Combine these two arrays into a third one-dimensional array. When combining, pass only non-prime numbers. Calculation of the number of times each element occurs on the one-dimensional array you combine. Create a new two-dimensional array with the elements you calculated with these values. For example; Combined array: 10, 20, 15, 10, 8, 12, ... Two-dimensional array: a [0] [0] = 10 a [0] [1] = 2 a [1] [0] = 20 a [1] [1] = 1 ... like. Then you output the software to have the first three sequences side by side. The two dimensional array is "Element - Quantity" analysis one after the other
Maanik
Not with your home works... but yes.
I am not saying that u will help in my homework i just say thatif I face any problem in doing programming so can u help me🙃
Anonymous
Yup
You can read the rules for further info
Anonymous
emergency help
/warn emergency warn
klimi
Dima
lmao
klimi
lmao
come pm
Dima
Anonymous
What about my query? I asked something now it's not showing Please tell the reason for removing.
Nameful
My all-important sticker remains though. Phew
ברני
Hey again, I got a task that I didn't understand well... Question 3 - to run Write a function that receives two sorted arrays [arrays 1 and 2] and their size, and another array [array 3] that is not initialized and sized As a sum of 2 + 1 array sizes. The function will insert into array 3 the values ​​from arrays 1 and 2 in a sorted manner. The insertion of the values ​​into array 3 must be done in one pass on each of arrays 1 and 2
ברני
what's the meaning "The function will insert into array 3 the values ​​from arrays 1 and 2 in a sorted manner. "?
ברני
They just want me to make a code that would take the numbers from 1 and 2 to 3?
Prince Of Persia
Hi
Prince Of Persia
There is any dynamic int class for c++?
Alex
hi. what do you mean dynamic?
Prince Of Persia
hi. what do you mean dynamic?
Like python int variables
Prince Of Persia
boost::cpp_int
Thanks Let me check
olli
what's the meaning "The function will insert into array 3 the values ​​from arrays 1 and 2 in a sorted manner. "?
merge both arrays into the third array to that it is sorted, e.g. from array1: [ 1, 5, 7 ] and array2: [ 4, 6, 6, 9 ] you shall generate array3: [ 1, 4, 5, 6, 6, 7, 9 ]
Andrian
can someone help me ?
Andrian
I want the results that come out is 123 132 213 231 312 321 but the results are 123 132 213 231 321 312 I want the finished result to start from the smallest number first
Andrian
I've searched on google and tried to change the code, but I still can't find a solution, thanks in advance
Andrian
Andrian
that's the code
olli
please share your code using pastebin services. You shouldn't expect people that want to run your example to copy your code from the image.
Maanik
Ur so strict😶
Manav
Ur so strict😶
That is to keep this chat clutter free.
Maanik
Ok,😐
Manav
Ok,😐
XD, just follow the rules on the pinned message, and you won't have to worry about getting warned.
Don Peter Joseph
https://pastebin.com/mtyPRqVr
Don Peter Joseph
i don't know where i am going wrong in this code
Don Peter Joseph
enter the no of elements:3 enter the elements in list:7 1 3 the unsorted array is :7 1 3 the sorted array is :1 180149090 3
Prince Of Persia
boost::cpp_int
thanks but it's not dynamic
Don Peter Joseph
this is the output
Tangent Alpha
you can start with int main( ) instead of void main( ) cuz main( ) always returns a value
moreover writing void main( ) and then returning 0 does not make sense
olli
Ur so strict😶
being strict is one of the reasons why stackoverflow is such a great resource. One should not expect decent answers if one doesn't put any effort into asking in the first place.
Prince Of Persia
did you have seen python int vars?
Prince Of Persia
you can put any number to it
Prince Of Persia
and it will resize when it need
Prince Of Persia
I need to doing + - / * % on a big number
Prince Of Persia
the number can be so big or so small I need to same thing in all number that I will get in input
Prince Of Persia
for this I try to find a dynamic int
Tangent Alpha
and please for the love of god write codes cleaner
olli
i don't know where i am going wrong in this code
your sorting logic isn't really correct. but did you mean to write >= ? Otherwise you might access the array out of bounds for (int j = i - 1; j <= 0; j--) ^^^^^^
olli
yeah.i corrected it. But still some problem in swapping
Yes, you should probably compare and swap adjacent elements in the array
Andrian
Andrian
that's the code sir
olli
please use pastebin services (e.g. https://paste.ubuntu.com/) the next time. If you want to have your permutations lexicographically sorted you need to use a more complex logic. e.g. you would need to do something like this (https://en.cppreference.com/w/cpp/algorithm/next_permutation) template<class BidirIt> bool next_permutation(BidirIt first, BidirIt last) { if (first == last) return false; BidirIt i = last; if (first == --i) return false; while (true) { BidirIt i1, i2; i1 = i; if (*--i < *i1) { i2 = last; while (!(*i < *--i2)) ; std::iter_swap(i, i2); std::reverse(i1, last); return true; } if (i == first) { std::reverse(first, last); return false; } } }
Anonymous
hey so I managed to create the basic skeletal structure for a problem statement that requires me to create a Linked List and insert elements in it such that after each insertion, the list is sorted according to an integer value stored in the class object that comprises the data of the linked list
Anonymous
for some reason there's a segmentation fault at the 3rd Iteration every time and I'm unable to figure out what's causing it
Anonymous
These are the methods and gdb verbose
Anonymous
void LinkedList::insert_increasing(const ShapePtr& p){ tail_insert(p); int flag; NodePtr p1; NodePtr lp = nullptr; do{ flag = 0; p1 = head; while(p1->getLink() != lp){ if(p1->getData()->getArea() > p1->getLink()->getData()->getArea()){ swap(p1, p1->getLink()); flag = 1; } p1 = p1->getLink(); } lp = p1; } while (flag); } void LinkedList::tail_insert(const ShapePtr& p){ Node newnode = Node(p); newnode.setLink(nullptr); NodePtr lst = head; if(head == nullptr){ head = &newnode; } else { while(lst != nullptr){ lst = lst->getLink(); } lst->setLink(&newnode); } }