Zoe
Member
I have this assignment with a ton of bit twiddling puzzles, and this one has stumped me.
I'm fairly certain the answers for all of those are online.........
At least they were 6 years ago.........
I have this assignment with a ton of bit twiddling puzzles, and this one has stumped me.
static void drawFlag(Graphics2D g){
g.setColor(new Color(8,41,140));
g.translate(100,100);
g.rotate(Math.toRadians(200));
fillStar(g,100,100,8);
}
static void fillStar(Graphics2D g,int x, int y, int r)
{
Polygon star = new Polygon(
new int[]{0,22,95,36,59,0,-59,-36,-95,-22},
new int[]{-100,-31,-31,12,81,38,81,12,-31,-31},10);
for (int i=0;i<8;i++)
{
double a = Math.PI*2*i/16;
g.translate( 48*Math.cos(a), 48*Math.sin(a));
g.scale(r/100.0,r/100.0);
g.fillPolygon(star);
g.scale(100.0/r,100.0/r);
g.translate(-48*Math.cos(a),-48*Math.sin(a));
}
}
@echo off
set /a counter=0
set /p num= Number of Searches:
:loop
if %counter% lss %num% (
start chrome.exe http://google.com/search?q=%counter%
set /a counter=%counter%+1
goto :loop
)
pause
So I'm done with school, and I feel like I haven't even really scratched the surface of learning - there are so many things I want to read/learn. And I am forcing myself to get some learning here and there.
One thing I really need to get better with is intermediate to advanced database design/development. I don't think it matters if it's in SQL server or Oracle or whatever, I just want to be more comfortable with the architecture of a good DB.
I really wish there was a KhanAcademy like website for all my programming needsI function best with that sort of thing, interactive tutorials that can track my progress/nudge me in the right direction.
As it is right now I feel like there are SO many things I don't know, and so many possible combinations of language, I am a bit lost - do I focus on mastering what I know, or branching out a bit more and covering more of my bases? Sigh.
First time posting in here so hopefully somebody can help me out. I'm writing a really simple batch file to do searches on a search engine. right now I just have it doing a looping search using google to search for an incrementing number. The problem is that each search opens a new tab. Any ideas how to keep the searches all confined to one tab? Here's the code I've got.
Code:@echo off set /a counter=0 set /p num= Number of Searches: :loop if %counter% lss %num% ( start chrome.exe http://google.com/search?q=%counter% set /a counter=%counter%+1 goto :loop ) pause
Congrats on being done with school. Don't get overwhelmed with everything you don't know; it'll never change. You'll never know more than the tip of the iceburg. So don't feel like you have to learn everything, or even have a casual understanding of everything, anytime soon. Focus on a very small subset, like say Android programming, or websites in C# (ASP.NET MVC) or maybe write a python script that gets information from some API related to a thing you're interested in, or or \anything\. Just try to make things that you either get paid to do, or you really enjoy. Knowledge will come along the way.So I'm done with school, and I feel like I haven't even really scratched the surface of learning - there are so many things I want to read/learn. And I am forcing myself to get some learning here and there.
One thing I really need to get better with is intermediate to advanced database design/development. I don't think it matters if it's in SQL server or Oracle or whatever, I just want to be more comfortable with the architecture of a good DB.
I really wish there was a KhanAcademy like website for all my programming needsI function best with that sort of thing, interactive tutorials that can track my progress/nudge me in the right direction.
As it is right now I feel like there are SO many things I don't know, and so many possible combinations of language, I am a bit lost - do I focus on mastering what I know, or branching out a bit more and covering more of my bases? Sigh.
I was always confused about the const stuff until I read the section on this c++ faq:
http://www.parashift.com/c++-faq/const-correctness.html
extern char* labels[];
void foo( const char* needle, const char* haystack[], size_t n );
foo( "gaf", labels, N ); // error on loss of cv-qualifier
The former returns a const int, the latter is a const member function. A const member function "promises" not to modify the objects it operates on. This lets the compiler know that you can safely call this function on const objects.
That's the general idea I think, I'm not 100% certain on this.
(And I don't think there should be parentheses after const)
I was always confused about the const stuff until I read the section on this c++ faq:
http://www.parashift.com/c++-faq/const-correctness.html
Well, at the base level, you are checking:
x - y <= 0
x + (-y) <= 0
That is, whether the number is less than 0, or equal to 0. You're already checking for one, so check for the other, and decide whether one or the other is true.
I'm fairly certain the answers for all of those are online.........
At least they were 6 years ago.........
People here working with openCL?
So in my class, our instructor gave out some assignments for us to do as a practice test (not worth a grade) and i'm having problems with one.
The question asks us to find all prime numbers between 3 and 100. The hint he gives us says to use to nested loops. He then goes on to say to find out if a number n is prime, to loop from 2 to n - 1.
I've been trying to wrap my head around it, but I have no idea what it means by 2 to n - 1.
I have the outer for loop done to go from 2 and stop at 100, just having problems with the inner loop.
I just started a course on it.
Also, I hate regexp syntax![]()
Anyone have any experience with selling a piece of personally written software to companies?
I'm writing a program that I think some companies would like to buy. I'm still a few months out from being completed, probably, but I'm curious to see if anyone else has had any luck with something like this. I have no idea what I'll price it at either (or what a company might pay).
With no idea what it is and no idea what benefit it might bring to companies, how do you expect us to give a meaningful answer? But I can already tell you that it could be tricky to sell unless it's an AMAZING piece of software. Why?
Support.
Companies usually buy software from big software houses or develop it in-house because of exactly that. What guarantee do they have that you will be able to support their employees with problems or be able to fix bugs that arise 1-2 years after purchase?
If you can guarantee them that and your software is both fairly priced and exactly what they need, I can see it happening. Otherwise... tricky.
Support is a good point. I was considering selling as a yearly license kind of support/customization included or agreed to. The current plan I'm thinking about is to send out emails to HR people with a good overview and a full manual once I'm done to gauge their interest. Maybe ask them about pricing, what they're allowed and willing to spend, etc.
Also, to be fair, I didn't provide specific info because I wasn't really looking for specific advice. I'm more interested in hearing about things other people have gone through.
I took a C/C++ test today at Motorola. Considering that I had almost no contact with C++ in about 5 years (excluding reading this thread from time to time; probably under 1000 lines of code written during that period) I'm happy with how it went. Don't think I'll get the job, though.
It's all goodI'm sorry to hear thatI think most programming questions during job interviews are bullshit anyways... Good interviews focus on open-ended problem solving skills and not necessarily formalized design patterns and text-book terminologies. Read the first chapter on how many design pattern books begin and you begin to see why it's stupid to test terminology.
d[-_-]b;43060440 said:Sure, sorry I was just giving of an example of how I code, I suck at this whole practical approach, tried the whole divide and conquer but I suck at tying things together, I try to get a functional piece of code first and work my way from there,
Code:public static void main(String[] args) throws Exception { URL urldata = new URL("http://www.mangahere.com/mangalist/"); Document docdata = Jsoup.parse(urldata, 5000); Elements ele = docdata.select("div[class=list_manga]").select("li") .select("a"); ArrayList<Manga> lMangaList = new ArrayList<Manga>(); URL url; Manga lManga; Chapter lChapter; boolean bResume = false; for (int i = 0; i < ele.size(); i++) { if (ele.get(i).text().replaceAll("\"", "") .equalsIgnoreCase("Air Master")) bResume = true; if (bResume) { lManga = new Manga(); url = new URL(ele.get(i).attr("abs:href")); lManga.setTitle(ele.get(i).text().replaceAll("\"", "") .replace("'", "")); lManga.setIndexLink(url.toString()); System.out.println(lManga.getTitle()); Document docdata2 = Jsoup.parse(url, 5000); String ogImage = getMetaTag(docdata2, "og:image"); Pattern p = Pattern.compile("\\d+"); Matcher m = p.matcher(ogImage); if (m.find()) { lManga.setID(Integer.valueOf(m.group())); } lManga.setCover(docdata2 .select("div[class=manga_detail_top clearfix]") .select("img").attr("abs:src")); Elements ele2 = docdata2.select("div[class=detail_list]") .select("li").select("span[class=left]"); for (int j = ele2.size() - 1; j >= 0; j--) { lChapter = new Chapter(); lChapter.setTitle(ele2.get(j).text().replaceAll("\"", "") .replace("'", "")); Elements ele3 = ele2.get(j).select("a"); String lCheckLink = ele3.attr("abs:href"); // Parsing Actual Manga Page lPage; while (lCheckLink.contains("http://")) { url = new URL(lCheckLink); Document docdata3 = Jsoup.parse(url, 5000); Elements ele4 = docdata3 .select("section[class=read_img]").select("a") .select("img"); lCheckLink = ele4.attr("abs:src"); if (lChapter.getID().isEmpty()) lChapter.setID(lCheckLink.split("/")[6]); lPage = new Page(); lPage.setLink(lCheckLink.split("/")[8]); Elements ele5 = docdata3.select("span[class=right]") .select("a[class=next_page]"); lCheckLink = ele5.attr("abs:href"); lChapter.getPages().add(lPage); } lManga.getChapters().add(lChapter); } } }
Thanks practically the basic idea
I was hoping to get a better idea going forward, trying to be a better programmer in a sense, I look at some of my projects like months after and have trouble recognizing what I was trying to do, try to use Hungarian notation to make it a bit easier, for myself, m -> members, p -> parameters, l -> local variables before there names but sometimes i'm inconsistent when i'm trying to get it to work.
So I'm done with school, and I feel like I haven't even really scratched the surface of learning - there are so many things I want to read/learn. And I am forcing myself to get some learning here and there.
One thing I really need to get better with is intermediate to advanced database design/development. I don't think it matters if it's in SQL server or Oracle or whatever, I just want to be more comfortable with the architecture of a good DB.
I really wish there was a KhanAcademy like website for all my programming needsI function best with that sort of thing, interactive tutorials that can track my progress/nudge me in the right direction.
As it is right now I feel like there are SO many things I don't know, and so many possible combinations of language, I am a bit lost - do I focus on mastering what I know, or branching out a bit more and covering more of my bases? Sigh.
Need some help with program logic if anyone is interested!
I have to recursively generate and expression tree from a user entered string, but the only parameter I'm allowed to pass to this recursive function is the string (no pointers).
The function header is node * buildTree(string &express); , so it returns a pointer to the binary tree. I'm a little confused since any time I build a binary tree recursively I'm used to passing a pointer along with it as well as the data.
Our professor gave us the Algorithm for building the tree but I'm still not putting two and two together here. The user enters an expression in prefix(polish) notation and we build an expression tree from that. Based on our professors notes the tree is built by doing the follow:
- Generate the node with null references to the left and right.
- If the "token" is an operand, just return the reference to the (leaf) node
- Otherwise
- a. Recursively generate a tree node and link it as the left subtree
- b. Recursively generate a tree node and link it as the right
- subtree
- c. Return the reference to the resulting (internal) node
I guess the problem I'm running into is that we have to build a tree from a single string and one function call instead of passing the function a single character at a time and using a loop to build the tree. I'm also not sure how to do this recursively without passing a pointer like I have for other binary trees. I have a feeling I'm either over thinking the crap out of this or I really have absolutely no idea what I'm doing.
He said we're allowed to use as many functions as we'd like along side the required functions he gave us, so I guess I could try something like that.
node * buildTree(string &express)
{
node *n = new node();
n.left = buildTree( splitLeftSide( express ) );
n.right = buildTree( splitRightSide( express ) );
n.leaf = getLeafValue( express ); // null for non-leafs
return n;
}
This gives me a bit to work with here, thanks you two.
Hi guys, I was wondering if you could help with something. I have a string that contains this "BBB 2" I want to eliminate the whitespace so that it looks like this "BBB2" . I have tried many things but it still doesn't work, any ideas? I'm programming in Java.
Good luck.
One more thing, while recursion if well suited for handling these kinds of problems, it is limited by the stack size. So a series like:
x = 1 + ( a + ( b + ( c + ...
...will eventually break your code.
It's probably useful to find out what the exact limit is and mention it in your comments. It's not a problem with real world applications, but it's always good to be on the anal-retentive side![]()
Looking at it, it seems as if you're using the assignment operator in several places (=), instead of the equality operator (==).[...]
Looking at it, it seems as if you're using the assignment operator in several places (=), instead of the equality operator (==).
"if (current_size = 0)"
"if (current_size = 1)"
etc.
So I'd recommend fixing that first.
I don't know a lot about C++, but why would that be a compiler issue? Seems like a problem with the code (especially those assignments instead of comparisons)That would have definitely been an issue. I booted up Linux and it compiles/runs fine (although not correctly). It must be a compiler issue. I'm doing a fresh install of Cygwin.
I don't know a lot about C++, but why would that be a compiler issue? Seems like a problem with the code (especially those assignments instead of comparisons)
Hi guys, I was wondering if you could help with something. I have a string that contains this "BBB 2" I want to eliminate the whitespace so that it looks like this "BBB2" . I have tried many things but it still doesn't work, any ideas? I'm programming in Java.
It was probably the assignment vs. equality thing I mentioned earlier - to explain, look at the older version of your dequeue function:Maybe "compiler issue" is not what I meant to say. I guess I should have said "an issue not related to my code".
It runs fine on Linux. Truth is, I don't know why it is giving me that error.
void queue::enqueue(int item){
if(current_size = 0) {
back_p = new node(item, NULL);
front_p = back_p;
++current_size;
}
if(current_size >= 1) {
back_p->next = new node(item, NULL);
back_p = back_p->next;
++current_size;
}
}
if ((current_size = 0) != 0)
int queue::dequeue(){
if(current_size >= 2) {
node* old_front = front_p;
int temp = old_front->data;
front_p = front_p->next;
delete old_front;
--current_size;
return temp;
}
if(current_size = 1) {
node* old_front = front_p;
int temp = old_front->data;
front_p = NULL;
back_p = NULL;
delete old_front;
--current_size;
return temp;
}
/*if(current_size = 0){
error("Can't dequeue an empty queue");
}*/
}
if ((current_size = 1) != 0)
[..]
Ah np. I've actually had the same problem when I was doing my first few projects in C++...Thanks for the reply. That was my first time compiling/programming on windows so it was quite new to me. That was a very stupid mistake I made.