klimi
/warn google play promotion
BnnD
hi, how can i validate against the characters such as alphabet in the code below
BnnD
#include <iostream> #include <string> #include <cctype> //alphabet character validation using namespace std; int main () { int num; string rom_num; cout« "Roman Numeral Converter"«endl; cout «"\nEnter Number ( 1- 10 )"«endl; cin » num; while (( num < 1 )|| (num > 10)) //|| ( num == char( num ))) { cout «"\nEnter number between range of 1 and 10\n"«endl; cin » num; } switch ( num ) { case 1: { rom_num = " I "; cout «"\nThe roman numeral is "« rom_num«endl; } break; case 2: { rom_num = " II "; cout «"\nThe roman numeral is "« rom_num«endl; } break; case 3: { rom_num = " III "; cout «"\nThe roman numeral is "« rom_num«endl; } break; case 4: { rom_num = " IV "; cout «"\nThe roman numeral is "« rom_num«endl; } break; case 5: { rom_num = " V "; cout «"\nThe roman numeral is "« rom_num«endl; } break; case 6: { rom_num = " VI "; cout «"\nThe roman numeral is "« rom_num«endl; } break; case 7: { rom_num = " VII "; cout «"\nThe roman numeral is "« rom_num«endl; } break; case 8: { rom_num = " VIII "; cout «"\nThe roman numeral is "« rom_num«endl; } break; case 9: { rom_num = " IX "; cout «"\nThe roman numeral is "« rom_num«endl; } break; case 10: { rom_num = " X "; cout «"\nThe roman numeral is "« rom_num«endl; } break; } return 0; }
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 !
Ellipsis
Hi
klimi
Hi
Youssef
What is the purpose of function return pointer?
Ludovic 'Archivist'
What is the purpose of function return pointer?
Jumping back to the position in the executable before you called the function (aka, resuming to the caller)
Ludovic 'Archivist'
I'm new to lambda and find lambda not easy to read. Do you guys use lambda a lot at work?
I do use them a lot. Having a readable indentation is very important there
Igor🇺🇦
NXiss7
I'm new to lambda and find lambda not easy to read. Do you guys use lambda a lot at work?
It's pretty simple actually, especially after knowing implementation or details. However, it's not much used but a good to have feature.
NXiss7
I'm new to lambda and find lambda not easy to read. Do you guys use lambda a lot at work?
It's also pretty useful as a callback function. You know, if you omit access operator (leave square brackets empty) it acts like a function.
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
Anonymous
What to read bro ???
Brown
What to read bro ???
The original Dennis M Ritchie book.
Anonymous
I need to buy it ???
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
Please bro can you send me the link !!! 😅😅😅
Duckduckgo it yourself doesn't matter which link. Just make sure its the second edition
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
Igor🇺🇦
Books are essentials in the 21st century, too
Why do you need to kill trees when you can have same info in digital format?
Mat
Or ebooks 🤷‍♂
klimi
Why do you need to kill trees when you can have same info in digital format?
You know that you need power to view that eBook so coal is burnt to show that?
Mat
You know that you need power to view that eBook so coal is burnt to show that?
That, too. Everything has its good and bad side Kinda it, though
Igor🇺🇦
You know that you need power to view that eBook so coal is burnt to show that?
No, I live in a country with majority of electricity from nuclear power 😜
Dima
In a majority of budget split lol
klimi
No, I live in a country with majority of electricity from nuclear power 😜
And that device you watch it on has came from where?
Dev
Why does the memory of 4GB ram utilize only 2GB instead of 4GB?
Dima
what?
I_Interface
What the hell ?
Dev
are you talking about x32?
I am not sure it is x32 or x64
Dev
I tried to find out on Google but failed to do so...
Anonymous
hello?
Dima
welcome
Anonymous
ty
I_Interface
klimi
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?
Anonymous
if it’s large enough, use pastebin.com
yeah i already have it in a .txt file
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.
Francisco
yeah i already have it in a .txt file
We don't want a .txt file, we want a pastebin/compiler explorer link
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
i was trying to send the link but i couldn´t
It's a measure to prevent spam
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....