Anonymous
Ok thanks sir ...
Anonymous
I ll try it now and let you know .. the output
Anonymous
Not accepting code again i might send you the whole question
Talula
#include<iostream> #include<bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; while (t>0) { int n; cin >> n; unsigned long fact = 1; for (int i = 1; i <= n; i++) { fact *= i; } cout << fact << endl; t--; } return 0; }
Anonymous
Talula
Your program doesn't do anything like that.
Anonymous
Its a factorial program i guess .
Anonymous
/warn screen photo
Apk
Input Range seems small enough....
labyrinth
are there other implementation on polymorphism with c++ other than virtual functions and vtables ?
Talula
You have to take inputs first store them in array and then give output... what you're doing is giving output when you get input...
Talula
You'll have to do it yourself... not going to tell you how to do it.
Anonymous
Ok ......
Anonymous
I got the problem ..
Anonymous
And its easy to sotre that value in the array thanks for the help sir .
MicroNG
Starting c++ lecture series. Can see IT and CS learning
Henry
Hi please my system() is not working
Henry
What do i do?
Talula
Hi please my system() is not working
system()? What, where, how, when... in other words, what are you talking about?
Henry
When i system("dir") Nothing shows up
Henry
hastebin https://hastebin.com/
Anonymous
Can someone help provide a more efficient code for this?
Anonymous
#include <iostream> using namespace std; int main() { int num1, num2, num3; cout << "Input 3 numbers with spaces between then press enter!" << endl; cin >> num1 >> num2 >> num3; if ((num1 <= num2) && (num1 <= num3) && (num2 <= num3)) cout << "The numbers in ascending order is: " << num1 << " " << num2 << " " << num3 << endl; else if ((num2 <= num1) && (num2 <= num3) && (num1 <= num3)) cout << "The numbers in ascending order are: " << num2 << " " << num1 << " " << num3 << endl; else if ((num3 <= num1) && (num3 <= num2) && (num2 <= num1)) cout << "The numbers in ascending order are: " << num2 << " " << num1 << " " << num3 << endl; else cout << "The numbers in ascending order are: " << num3 << " " << num1 << " " << num2 << endl; return 0; }
Anonymous
This is my solution to a question requiring 3 numbers from a user input to be arranged in ascending order but I feel that my solution is not practical in the case where input is huge.
Anonymous
Thought about using the switch case but was limited by the constant expression or maybe I just don't know how to go about it
Anonymous
Can't you store inputs in a vector and use std::is_sorted?
Well, I am a novice in c++ and I haven't gotten to vectors yet.
Anonymous
Not yet an array expect, I am going strictly by a textbook
Igor🇺🇦
If you know how many numbers you have you can use either C array or std::array
Anonymous
I will be sure to consider that when I study arrays
Anonymous
Thanks
Andrey
Why do I get segmentation fault? #include <stdio.h> #include <string.h> #define LENGTH 10242 int main(int argc, char **argv) { char buffer[LENGTH][LENGTH]; for (int i=0; fgets(buffer[i], LENGTH, stdin) != NULL; i++) { printf("%s", buffer[i]); } for (int i=0; buffer[i] == 0; i++) { printf("%s", buffer[i]); } }
Andrey
>10242 * 10242 char array duh
how can I after giving values to buffer[10242][100] can reassign them?
Mдtt
Which is the Linux limit on the total number of symlinks that a single file can traverse? (e.g. in Linux 2.6 the limit is 40 symlinks).
Andrey
seems like you need dynamic allocation
but without malloc it isn't possible?
Vlad
there's calloc and realloc)
Ammar
but it works 🤔
buffer[i] == 0 will always be false, so the second loop will never run.
Ammar
how can I after giving values to buffer[10242][100] can reassign them?
You can do the same as the first loop. Just assign a value to it, it will overwrite the value.
Andrey
but it works
Ammar
but it works
How could you say it work? Which are your inputs and your program outputs?
Andrey
How could you say it work? Which are your inputs and your program outputs?
it was the input data from a text file, and i see this output in terminal 🤔
Ammar
The second won't run.
Andrey
ah, yes, you are right
Andrey
how can i fix it?
Ammar
I don't know what are you going to do. So I don't have a clue what advice should I give.
Ammar
Please explain your need.
Ammar
I would prefer to discuss technical thing on the group.
Andrey
ok, so I want to read data from a text file, to work with this data, and then print it to another file
Ammar
or append the content?
V01D
Arrays are the same
Arrays and vectors aren't the same
Andrey
So we can conclude you want to copy file a to file b?
I'll give you example for instance, i am running my program like: ./prog drow 5 acol 3 < text.txt > text2.txt drow - delete row acol - append columns and I want to save all the data in an array to later work with and after the work is done to save it to the new file
ברני
Hey, I had to do a function array on a task, But I don't understand why it won't compile, the error says that the problem is the scanf but I don't understand why,,,https://onlinegdb.com/rJsAPDYFP
Andrey
Still, I can't get the point.
I have to make the program which must do: Table modifications cause the table, rows and columns to be enlarged or reduced. Multiple commands can be entered to edit the table. In this case, multiple command line arguments will be specified as a sequence: Table editing commands: irow R - inserts a table row before row r > 0 (insert-row). arow - adds a new table row to the end of the table (append-row). drow R - deletes row number r > 0 (delete-row). drows N M -deletes rows n to M (N <= m). In the case of N = m, the command behaves the same as drow n. icol C -inserts an empty column before the column given by the number C. acol - adds an empty column after the last column. dcol C -deletes column number C. dcols N M - deletes columns N to M (N <= m). In the case of N = m, the command behaves in the same way as dcol n. and I do not have idea what is the best approach to this problem is, i tried to do this: char buffer[LENGTH] for (int i = 0; fgets(buffer, LENGTH, stdin) != NULL; i++) { for (int x = 1; x < argc; x++) { if (strcmp(argv[x], "drow") == 0) { deleting row here } if (strcmp(argv[x], "acol") == 0) { adding column here } } printf("%s", buffer); } but at some point it is difficult to make some functions
Anonymous
How to print every word of a string individually like the first word when we want similarly the second word when we want
Ammar
ברני
Hey again, I had a typo mistake on my code first, but now it's seems my last function doesn't work right.. it suppose to put the even numbers from the first and second array in to the third.. can any one give me a hint why it doesn't work please? https://onlinegdb.com/B16X5DtYv
Winkee
does anyone know of a open network library that support c++20's coroutine
Ammar
can you write me please an example of a struct look like?
I don't have time to write the example. As I will have to work on the next few minutes. But here are the references you can look for: 1. C/C++ struct. 2. man 2 mmap. 3. man 2 open. For the man, if you use Linux, you can just type it on your terminal. Linux distribution usually comes with Linux Programmer's Manual. Feel free to come back here and ask for your problem. You can ask me again to write the example later.
Anonymous
If the first condition is satisfied, I want to get the (k + 1) th number from the file and print it, if the second condition is satisfied, I want to get the (k + 2) th number from the file and print it. In the loop, k increases by 1,2,3,4.How to do this without cursor and array.(There are only as many numbers ,new Lines and spaces in the file that I don't know)