HaiNahi
What is this algorithm analysis
HaiNahi
Engineers don't know coding, they can't write large programs
Pavel
What is this algorithm analysis
Have you tried to read about it on the internet?
HaiNahi
Have you tried to read about it on the internet?
Yeah I saw a youtube video, they told like nested loop is worse than a simple loop
HaiNahi
Worse in any computer
HaiNahi
If we can't remove a nested loop there is no good to fix others outside
Alejandro
Do you mean engineers or software engineers xD
HaiNahi
Do you mean engineers or software engineers xD
lol I asked a engineer studying, he told he can't code a large program seeing my code :/
Alejandro
lol I asked a engineer studying, he told he can't code a large program seeing my code :/
Studying what engineering? Software engineering is very different from mechanical engineering or chemical engineering xdddd
ninja
What is this algorithm analysis
do you know what is algorithm
Pavel
If we can't remove a nested loop there is no good to fix others outside
On a large scale you need to reduce time complexity first, yes. Since O(n^2) will more likely be a bottleneck than O(n). But every case needs investigation, there's no one answer that covers every situation.
HaiNahi
algorithm is any relation between input and output
ninja
algorithm is any relation between input and output
algorithm analysis is just to check what's it efficiency and how much we can make that algo better(in general)
ninja
you shoud google this type of Que
HaiNahi
you shoud google this type of Que
How are math function coming in algorithms
HaiNahi
O(n ln n)??
Anonymous
I watched this talk last night, was great so I decide to share it here.. https://youtu.be/9AhS9DuXv00
HaiNahi
I was thinking what if I write program for any much fast computer
HaiNahi
infinitely fast
HaiNahi
What could we do with that, rather than compressing files
HaiNahi
When we would compress a large program, the code of it would generate, which is perfectly small, may be smaller than the real code, magically
ninja
can i say dead man walking😂😂
Anonymous
infinitely fast
We need fast processors to fast computing
HaiNahi
What if we write, and that would be pure IQ there is no engineer who can make it faster
HaiNahi
My question is if such a computer comes in the world, could we bring a revolution
HaiNahi
If we can make intelligence out of it, that would mean intelligence is mathematical rather than evolution
Pavel
My question is if such a computer comes in the world, could we bring a revolution
We need to solve a lot of real-world physics problems for that, e.g. overheating problem that now doesn't let to put more transistors to the chip, and well.. there's speed of light limitation still. Anyway this is a wrong chat for such discussions. There's a better place for that:
ninja
olli
If we can't remove a nested loop there is no good to fix others outside
It heavily depends though. Nesting loops does not say anything about complexity, it can be even O(1)
数学の恋人
oh come on I can't put a screenshot now?
数学の恋人
anyways, I'm trying something like, inline Types::Byte Mem::operator[](Types::DWord address) const { // asserting that the address is always less than MAX_MEM assert(address <= MAX_MEM); return Data[address]; // Here I am getting a warning, which suggests me to use gsl::at() }
B S
I want to find factor of any no. Input 4 Output 3 1 2 4
B S
How can I print numbers of factor?
B S
Int n; Cin>>n; for(int i=0;i<=n;i++){ if(n%i==0){ cout<<i<<" "; } }
B S
I want to find factor to any no. Example Input 4 Output 3
B S
Please help me some one
Anonymous
Please help me some one
U know u can google...
Anonymous
See this example
Why? Code to find factors in every languages is everywhere on the net...
B S
I want to find factor to any no. Example Input 4 Output 3
Please help me some one for my desire output
B S
Try googling
I can't found😢
Anonymous
What did u search for?
B S
Factor of 4 Is 1 ,2 ,4 I want to print 3 as answer number
Anonymous
Factor of 4 Is 1 ,2 ,4 I want to print 3 as answer number
No i asked what did u search in google? What is the search phrase?
B S
How to find no of factors?
Anonymous
Then u get math answers i suppose?
olli
what is that gsl::at() thing? I know how to use it, but why exactly that? and what about alternatives? I expect something like iterators
gsl::at() is somewhat similar to the at() methods on STL containers, it performs a bound check and terminates on failure instead of relying on UB. https://docs.microsoft.com/en-us/cpp/code-quality/c26446?view=msvc-160 And yes, sending pictures is disabled because nobody likes to read code of a blurry photo of a screen :)
B S
No I got whole code but I did not get my desired output
B S
Factor of 4 Is 1 ,2 ,4 I want to print 3 as answer number
Anonymous
This
U know u can add a variable for counter and add 1 to it for every factor... just saying
Anonymous
Or refine the google term :)
数学の恋人
or nvm, I'll google
数学の恋人
there is not such thing lol it's for vectors and dynamic iterator tyeps
olli
could you tell me where std::at() is defined? and yeah what I wanted to share wasn't code but anyways, I agree with the reason
there is not std::at, but std::vector:at is probably the most famous one https://en.cppreference.com/w/cpp/container/vector/at
olli
yeah got you
unfortunately your example does not show the type of Data, but if it is an array/Container/.. you can do return gsl::at(array, index); Or you could disable the warning if your code makes sure not to access data out of bounds.
@𝑺𝒐𝒃𝒌𝒂
#cs50
Brian
#include <iostream> using namespace std; int sumoftotal (int A[],int size) { int sum=0,i; for(i=0;i<size;i++) { sum+=A[i]; } return sum; } float mean(int *A,int size) { int i; float sum=0; float avg; for(i=0;i<size;i++) { sum+=A[i]; } avg=sum/10; return avg; } int big(int *A,int size) { int large,i; large=A[0]; for(i=1;i<size;i++) { if(A[i]>large) large=A[i]; } return large; } int low(int *A,int size) { int small,i; small=A[0]; for(i=1;i<size;i++) { if(A[i]<small) small=A[i]; } return small; } int main() { int A[10],i,large,small,a; a: int size=sizeof(A)/sizeof(A[0]); cout<<"Enter marks of ten subjects: "; for(i=0;i<size;i++) { cin>>A[i]; if(A[i]>=0 && A[i]<=100) { continue; } system("cls"); cout<<" input value not in range [0-100]"<<endl; goto a; } int total=sumoftotal(A,size); cout<<"the total is "<<total<<endl; float avarage=mean(A,size); cout<<"avarage is "<<avarage<<endl; if(avarage>70) { cout<<"Grade is A "<<endl; } else if(avarage>=60 && avarage<=69) { cout<<"Grade is B "<<endl; } else if(avarage>=50 && avarage <=59) { cout<<"Grade is c "<<endl; } else if(avarage>=40 && avarage<=49) { cout<<"Grade is c "<<endl; } else { cout<<"Grade is F"<<endl; } int ttl=big(A,size); int tss=low(A,size); cout<<"smallest mark "<<tss<<endl; cout<<"largest mark "<<ttl<<endl; return 0; }
Brian
#include <iostream> using namespace std; int sumoftotal (int A[],int size) { int sum=0,i; for(i=0;i<size;i++) { sum+=A[i]; } return sum; } float mean(int *A,int size) { int i; float sum=0; float avg; for(i=0;i<size;i++) { sum+=A[i]; } avg=sum/10; return avg; } int big(int *A,int size) { int large,i; large=A[0]; for(i=1;i<size;i++) { if(A[i]>large) large=A[i]; } return large; } int low(int *A,int size) { int small,i; small=A[0]; for(i=1;i<size;i++) { if(A[i]<small) small=A[i]; } return small; } int main() { int A[10],i,large,small,a; a: int size=sizeof(A)/sizeof(A[0]); cout<<"Enter marks of ten subjects: "; for(i=0;i<size;i++) { cin>>A[i]; if(A[i]>=0 && A[i]<=100) { continue; } system("cls"); cout<<" input value not in range [0-100]"<<endl; goto a; } int total=sumoftotal(A,size); cout<<"the total is "<<total<<endl; float avarage=mean(A,size); cout<<"avarage is "<<avarage<<endl; if(avarage>70) { cout<<"Grade is A "<<endl; } else if(avarage>=60 && avarage<=69) { cout<<"Grade is B "<<endl; } else if(avarage>=50 && avarage <=59) { cout<<"Grade is c "<<endl; } else if(avarage>=40 && avarage<=49) { cout<<"Grade is c "<<endl; } else { cout<<"Grade is F"<<endl; } int ttl=big(A,size); int tss=low(A,size); cout<<"smallest mark "<<tss<<endl; cout<<"largest mark "<<ttl<<endl; return 0; }
Accepts 10 marks,find total, avarage, grade it, display the highest and lowest marks, doesn't accept any mark out of range of (0-100)
Anonymous
Accepts 10 marks,find total, avarage, grade it, display the highest and lowest marks, doesn't accept any mark out of range of (0-100)
Because of this. if(A[i]>=0 && A[i]<=100) { continue; } system("cls"); cout<<" input value not in range [0-100]"<<endl; goto a; Looks like not your code or else you'd understand what you have done.
Brian
you forgot to put those statements under else{} I guess.
Used continue hense no need ls of else
Anonymous
It's correct,hear am indicating that if the marks is outside that range (0-100),then it should revoke, display it's outside the range and to retry
retry just for the specific cin>>A[i]; inside the for loop which returns false for A[i]>=0 && A[i]<=100 ?
asterix
Hi Is there some way to get source code of c as like we can get for php or other language. I want to know internals of preprocessor
klimi
you can get for example the source code of gcc
asterix
you can get for example the source code of gcc
But that's much complex due to extra stuffs. I mean something which relates to original c as in unix era
asterix
you can get for example the source code of gcc
Do we always have get the source of compilers, gcc or clang? Is there anything which strips down only to the language implementation?