klimi
/warn google play promotion
BnnD
hi, how can i validate against the characters such as alphabet in the code below
Vikas
Hloo🙌
Anonymous
#include<iostream>
#include<chrono>
#include<random>
#include<cstdlib>
#include<vector>
#include<fstream>
#include<stdint.h>
#include<algorithm>
using namespace std;
using namespace std::chrono;
int found=0;
int notfound;
double ltimex = 0;
double lavgtime = 0;
double btimex = 0;
double bavgtime = 0;
float comparison=0;
float position=0;
int linearsearch(vector<int> a, int key, float &position){ //linear search
int j;
for(j=1; j<a.size(); j++){
if(key==a[j]){
position = j;
found++;
break;
}
}
if(position == j){
return position;
}
else
{
notfound = -1;
return notfound;
}
}
int binarysearch(vector<int>a, int first, int last, int key, float &comparison){ //binary search
int l=a[first];
int r=a[last];
if (r >= l) {
int mid = l + (r - l) / 2;
comparison++;
if (a[mid] == key)
return mid;
if (a[mid] > key)
return binarysearch(a, l, mid - 1, key, comparison);
return binarysearch(a, mid + 1, r, key, comparison);
}
return -1;
}
int main(){
int i,j,l;
srand(time(0));
for(i=120; i<=3600; i=i+120){
vector<int>a;
for(j=0; j<100; j++) //loop for test case, 100
{
for(int k=1; k<=i-1; k++){
int z = rand()%i+100;
a.push_back(z);
}
int key = rand()%i+100;
sort(a.begin(), a.end());
//time functions.
//linear search
auto start = high_resolution_clock::now();
linearsearch(a,key, position);
auto stop = high_resolution_clock::now();
ltimex = duration_cast<microseconds>(stop - start).count();
lavgtime = lavgtime + ltimex;
// //binary search
auto bstart = high_resolution_clock::now();
binarysearch(a,0, i,key, comparison);
auto bstop = high_resolution_clock::now();
btimex = duration_cast<microseconds>(bstop - bstart).count();
bavgtime = bavgtime + btimex;
}
comparison = comparison/100;
position = position/100;
cout << "\nAverage Time taken by linear function: "<< lavgtime << " microseconds";
cout << "\nAverage Time taken by binary function: "<< bavgtime << " microseconds";
ofstream fout;
fout.open("data.csv", ios::out | ios::app);
while (fout)
{
if (position != -1)
fout<<i<<","<<lavgtime<<","<<position<<","<<bavgtime<<","<<comparison<<"\n"; //size of array, linear, postion, binary, comparison
break;
}
fout.close();
}
return 0;
}
Anonymous
I ran the program in gdb mode on ubuntu
Anonymous
0x00007ffff74d69e9 in sysmalloc (nb=nb@entry=1440,
av=av@entry=0x7ffff782ec40 <main_arena>) at malloc.c:2321
2321 malloc.c: No such file or directory.
returns this error
AJAY
Hlw
many
I'm new to lambda and find lambda not easy to read. Do you guys use lambda a lot at work?
Youssef
Hello guys !
Nameful
Ellipsis
Hi
klimi
Hi
Youssef
What is the purpose of function return pointer?
Ludovic 'Archivist'
Igor🇺🇦
Brown
Whats the difference b/w these ?
Null
Hey guys, I am new here...
Is there anyone who can help me to make a program.
I have to make a program that will sort the ".csv " data from the file which will store Names and percentage of the candidates using "qsort" and that program will have DMA(Dynamic).
Null
Sorry for my bad English
Anonymous
I don't know any thing about C language
Anonymous
Please help me out
Brown
Anonymous
What to read bro ???
Anonymous
I need to buy it ???
Anonymous
Anonymous
You can read the second edition pdf online search for it
Anonymous
I have the whole book printed and binded actually xD
Anonymous
Please bro can you send me the link !!! 😅😅😅
Anonymous
Should say ANSI C in the cover
Anonymous
Ok bro thanx
Anonymous
I got it
Mat
Read the rules, please
Igor🇺🇦
I got it
Or you can advance to 21 century and use Web😉
Something like https://www.cprogramming.com/tutorial/c-tutorial.html
Mat
Mat
Mat
Or ebooks 🤷♂
Mat
Igor🇺🇦
Perodaah
Dima
In a majority of budget split lol
klimi
Dev
Why does the memory of 4GB ram utilize only 2GB instead of 4GB?
Dima
what?
I_Interface
What the hell ?
Dima
Dev
I tried to find out on Google but failed to do so...
Anonymous
hello?
Dima
welcome
Anonymous
ty
I_Interface
klimi
Dima
I_Interface
Anonymous
look, i have a doubt with my c code in one specific part, the thing is that i am spanish so the code is already in spanish but, the trouble is on one character so maybe you could find what is not working properly
Anonymous
should i send the code?
Dima
Anonymous
hope that you guys could help me; at the end of the code there is a part which is alumno=f, so my question is, why when i compile it the value of alumno is 106 when it could not be bigger than 5 because 'f' is the variable of the (for structure) and it has been initialized f=0.
klimi
Ramón T:
https://pastebin.com/TW4bYMax
Anonymous
that´s it
Anonymous
i was trying to send the link but i couldn´t
Francisco
Anonymous
ah okay
Anonymous
francisco eres español?
Francisco
Sí, but this is an English only group
Anonymous
ok then
Francisco
That's an Spanish group
Anonymous
ty so much Fran
klimi
Chm....
klimi
Anonymous