Dima
lol
Dima
/ban 1305811052
ברני
You probably don't want to start at index 0 again. If you want to fill the remaining places you could start at userSize instead int morePlace(int arr[], int userSize, int size) { int counter = 0; for (int i = 0; i < size; i++) { ^^^^^^^^^^ also, you probably don't want to run these comparisons over and over again, running them once or size times doesn't change the outcome of the condition if (userSize != size) { // <omitted> } else if (userSize == size) { // <omitted> } Instead you could do something like this (pseudocode) if array is full: print message else: for every unused array element: ask for an element to fill it with fi
Hey again.. I'm still with strugulse with the funtion... this is the task; Question 2 - to run Write a function that receives an sorted array with integers, its size, the number of actual members in the array and a number additional. The function will check if there is enough space in the array to enter the additional number) ie whether the actual number of numbers is small Array size. If not - return 0 and do not change the array. If so - enter the new number in its appropriate place (according to its size) and return 1. Write the main that asks the user for the number of numbers he wants to enter in the array, between 1 and the size of the array) Assume that The quantity is less than or equal to the size of the array. and this is what I did: https://onlinegdb.com/rJxbafR1cD Im sure the return also wrong but I dont understand what I need to do in the function to make it count the userSize and then to compare it to the define size and see if he can add one more to the array or not....
Prince Of Persia
hello guys how can I use a object in if() statement? example: .... MyBool b; if(b){ cout << "something"; } ....
Prince Of Persia
Prince Of Persia
Boolean::operator bool() const { return this->holder; }
olli
Hey again.. I'm still with strugulse with the funtion... this is the task; Question 2 - to run Write a function that receives an sorted array with integers, its size, the number of actual members in the array and a number additional. The function will check if there is enough space in the array to enter the additional number) ie whether the actual number of numbers is small Array size. If not - return 0 and do not change the array. If so - enter the new number in its appropriate place (according to its size) and return 1. Write the main that asks the user for the number of numbers he wants to enter in the array, between 1 and the size of the array) Assume that The quantity is less than or equal to the size of the array. and this is what I did: https://onlinegdb.com/rJxbafR1cD Im sure the return also wrong but I dont understand what I need to do in the function to make it count the userSize and then to compare it to the define size and see if he can add one more to the array or not....
first, morePlace should return 0, iff there is no more space in the array. The array is full if the user has requested to enter as many numbers as the array can fit. This is pretty much what the pseudo code in the previous messages does. Otherwise add a new number, potentially sorted (?), to the array. So regarding the return they basically want you to do int morePlace(int arr[], int userSize, int size) { if (/* more space available */) { // read and add input return 1; } else { return 0; } }
olli
ty so much ..I think my problem is that I don't understand return well.. its working now but can u tell me if I did it as the tasks asked? https://onlinegdb.com/r1x0KCJ9D
I don't think you have. If the user wants to write 4 elements, I would have expected morePlace to write the fifth one and not at index 9. Also I'm not completely sure what's up with the sorted part and whether the array still needs to be sorted after the function returns
ברני
I think only one more
So dose it matter to which index?
olli
So dose it matter to which index?
I would think so, because you might be able to call the function a second time
ברני
I did index 9 in case he'll do 8
olli
I did index 9 in case he'll do 8
well, but what if he does 3? or 6? or 2?
ברני
The tasks asked me to add only one.. If it want more I should add all the indexes, and I think I'll use switch?
ברני
Or I'm wrong?
olli
> in its appropriate place I guess it depends on your interpretation of "appropriate" - I would have thought you should add it at the next unused index
Jasur Fozilov 🐳
Delete the smallest element of the stack. does anyone know how to do that?
Anonymous
Hi guys, how can i make a random number in c?
-Bs¬
u can use rand() but idont know how it works
-Bs¬
Just remember that there is no 100% random number
Andrey
why do I get bus error?
Andrey
Anonymous
why are you returning NULL?
Anonymous
char* arr = "..."; Shooting the leg
Andrey
char* arr = "..."; Shooting the leg
hm? what's the problem here?
Anonymous
hm? what's the problem here?
What do you think a string literal is?
Anonymous
So what?
Andrey
i can't understand what problem do I have 😕
Anonymous
You have a problem writing in C while not understanding what are you doing
Andrey
so, what do i have to do to fix this problem?
Andrey
First: read a book
ok, but how to fix this problem? to write just arr also doesn't work
⟪ Ⓩ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
⟪ Ⓩub-Er ⟫
can you help me?
Tangent Alpha
can you help me?
Bro write the algorithm and then the code, if you have some issues then we can help
Iakovos
Hello guys! I really need your help if you can! I have to write a txt that the output should be like the photo's below. I've been trying for days now but can not fully complete it. I would appreciate if anyone can fill the code for me. (If you run it you could see that only the numbers missing) Thank you in advance! https://hastebin.com/safimipazo.md
⟪ Ⓩub-Er ⟫
can you write the code i just started the c course
Iakovos
⟪ Ⓩub-Er ⟫
#include <stdio.h> #include <stdlib.h> int main() { int dizi1[10], dizi2[10], toplam[20]={0}; int i; for(i=0;i<10;i++) { dizi1[i] = rand()%99+1; dizi2[i] = rand()%99+1; } int durum=1; int x=0; while(x < 10) { for(i=2;i<dizi1[x];i++) { if(dizi1[x] % i == 0) { durum = 0; break; } } if(durum) { toplam[x] = dizi1[x]; } x++; } int j=0; while(x < 20) { for(i=2;i<dizi2[j];i++) { if(dizi2[j] % i == 0) { durum = 0; break; } } if(durum) { toplam[x] = dizi2[j]; } x++; j++; } for(i=0;i<10;i++) { printf("dizi1 %d. sayi %d\n", i, dizi1[i]); printf("dizi2 %d. sayi %d\n", i, dizi2[i]); } for(i=0;i<20;i++) { printf("%d\n", toplam[i]); } }
Anonymous
is that time taken to do ???
Iakovos
Anonymous
What do you mean??
those numbers for random ASC DESC in selection,insertion,shell,quick sort
⟪ Ⓩub-Er ⟫
what
Iakovos
Yeah it is the duration of these methods of sorting, I extracted them from a file
Iakovos
Anyway you could help me if you please?
Anonymous
me noob 😅
Iakovos
Anyone here willing to help?
Raru
I need help in C , who can help me with one problem ?
Dima
is it exams week or what
Dima
lol
Dima
but read the rules first
⟪ Ⓩub-Er ⟫
Hadaward 'Solly'
pastebin
⟪ Ⓩub-Er ⟫
I couldn't do it in two dimensions
Hadaward 'Solly'
put your code in there and share the link here. It's simple and helpful for readers
Raru
This problem i need to do with fuctions but i can’t
Raru
#include <stdio.h> int a[20][20]; int swich_line(int n,int line_1,int line_2){ int val,i; for(i=0;i<=n;i++){ val=a[line_1][i]; a[line_1][i]=a[line_2][i]; a[line_2][i]=val; } return 0; } void main(){ int j,i,m,n,val,sum; printf("Introduceti numarul de linii: "); scanf("%d", &n ); printf("Introduceti numarul de coloane: "); scanf("%d", &m ); while(n<=1 || m<=1 ) { printf("Conditia n<1 si m<1."); printf("\nIntrodu n:"); scanf("%d", &n); printf("Introdu m:"); scanf("%d", &m); } sum=0; for (i=0; i < m; i++) { for ( j = 0; j < n; j++) {printf("Elementul[%d][%d]:", i,j); scanf("%d", &val); a[i][j]=val; if ((val>0) &&((val%2)==0)) { sum=sum+val; } } a[i][n]=sum; sum=0; }printf("\n\n"); for(i=0; i<n; i++) { for(j=0; j<m; j++) printf("%5d", a[i][j]); printf("\n"); }printf("\n\n"); for(i=0;i<m;i++){ for(j=0;j<m;j++){ if (a[i][n]<a[j][n]) { swich_line(n,i,j); } } } for(i=0;i<m;i++){ for(j=0;j<n;j++){ printf("%5d ",a[i][j]); } printf("\n"); } return 0; }
Dima
read the rules
Hadaward 'Solly'
dima, can you put in the rules "Minimum Requirements: Discrete Math"
Raru
read the rules
I read all the rules
Anonymous
What is the full form of conio.h. In #include<conio.h>
Hadaward 'Solly'
im currently studying discrete mathematics
congratulations ╰(*°▽°*)╯
Anonymous
congratulations ╰(*°▽°*)╯
remembering names for each symbols and laws is hard..
Hadaward 'Solly'
i hope you have a fun time with numerical optimizations
Hadaward 'Solly'
but dw, it's prob in a distant future