• Breaking News

    Sunday, March 25, 2018

    Merge and Quick Sort Algorithm Issue Ask Programming

    AskProgramming

    Merge and Quick Sort Algorithm Issue Ask Programming


    Merge and Quick Sort Algorithm Issue

    Posted: 25 Mar 2018 10:13 PM PDT

    This code currently opens and reads a .txt file with 25000 words in it and correctly sorts them using selection sort. However, while trying to additionally implement quick sort and merge sort for sort time comparisons, I am running into the issue of the vectors containing the unsorted list after going through the sorting algorithms. Does anyone see any problems that would be causing this? Any help at all is much appreciated. https://pastebin.com/3uQjJ0BY

    submitted by /u/HumpyTheHippo
    [link] [comments]

    Is there an IDE that allows me to focus on one or two pieces of the code at a time?

    Posted: 25 Mar 2018 12:40 PM PDT

    I often have trouble focusing more working memory 100% on everything related to my current programming task. I am looking for a programming methodology/workflow/setup that allows me to pay attention to a minimum number of things.

    For example, maybe an IDE where I press a "+" sign to add a function, and then I just see the code for that function in a box, but if I want to, I can choose to view another function side-by-side in another box.

    I am looking for something to clearly make it so that "this does this, that does that", instead of everything feeling like a giant mess (even if the code IS actually relatively clean and organized).

    I am already relatively familiar with design patterns, practices to write readable code, of course object-oriented programming etc. which can help with my attention, but I am looking for something more.

    This would mostly be for Python.

    submitted by /u/throwaway8878877
    [link] [comments]

    If you were to pick 3 languages to learn in order to make some side money, what would it be? And what sort of projects would you be doing?

    Posted: 25 Mar 2018 04:25 PM PDT

    What is the best way to update an old program?

    Posted: 25 Mar 2018 12:37 PM PDT

    I am interested in upgrading an old finite element software program written in fortran 77. Obviously, without seeing the code there is a limit to the advice that you can give, but I am wondering what is the best programming language to update it into. I am trying to deiced between C++ or Python. I thought that these languages would offer the ability to make the program more modular as compared to its current iteration.

    I want to make the program more accessible to users who are not as familiar with the way fortran works. Is this the path you would recommend?

    Thank you.

    submitted by /u/geodynamics
    [link] [comments]

    Basic question regarding arrays(C#)

    Posted: 25 Mar 2018 05:48 PM PDT

    I have this question on my assignment I'm trying to solve. Which says: "Write code that prompts the user for a positive integer, then create a string array of that length. Then prompt the user in a loop to enter in a value for each element of the array. Then print the created array on a single line separated by spaces."

    This is what I have so far:

     Console.WriteLine("Please enter a positive integer"); int userNum = Convert.ToInt32(Console.ReadLine()); string[] words = new string[userNum]; for(int x = 0; x<words.Length; x++) { userNum = 0; Console.WriteLine("Please enter a word"); words[userNum] = Console.ReadLine(); userNum++; } for(int z=0; z<words.Length; z++) { Console.WriteLine("{0} ", words[z]); } 

    My problem is that when I try to display the array at the end it only displays one word which is the last one which the user enters. How can I change this so that all of the user inputs get put into the array so I can display all? Thanks

    submitted by /u/roundhouseassasin
    [link] [comments]

    Anyone have experience with the Twillio API?

    Posted: 25 Mar 2018 05:27 PM PDT

    I am curious how the twillio api works? Can you parse data from an incoming text?

    I want to build a application where the user can send a ios or android "Contact" through sms and the api parses out the relavent information to carry out some function.

    EX: I have contact xyz So i press "Share contact" and I type in the twillio number to send the contact. Then the twillio app parses out the contact infromation.

    Is this possible? Any resources about this?

    submitted by /u/TunaOverEverything
    [link] [comments]

    Problem with Visual basic

    Posted: 25 Mar 2018 08:51 PM PDT

    can anyone tell me where i am going wrong with my code? This is what i have at the moment:

    Public Class Form1 Dim Username, Address, Email, City, State, Zip, Status As String Dim GPA, Years, Credit As Double Private Sub Btnclose_Click(sender As Object, e As EventArgs) Handles Btnclose.Click Me.Close() End Sub

    Private Sub Btnsubmit_Click(sender As Object, e As EventArgs) Handles Btnsubmit.Click Username = txtname.Text Address = txtaddress.Text City = TxtCity.Text State = Liststates.Text Zip = Txtzip.Text If (txtGPA.Text >= 3.0) And (Txtcredit.Value >= 600) And (Txtyears.Value >= 2) _ And ((50 * Txtyears.Value) + Txtcredit.Value >= 800) Then Status = "congratulations! You've been granted Unnconditional Acceptance" ElseIf (txtGPA.Text >= 3.0) And (Txtcredit.Value >= 600) And (Txtyears.Value >= 2) _ And ((50 * Txtyears.Value) + Txtcredit.Value >= 800) And (Liststates.text = "Kansas" Or "Oklahoma" Or "Texas") Then Status = "Congratulations! You've been granted Unconditional Acceptance with a $500 dollar scholarship" ElseIf ((txtGPA.Text >= 2.0) And (txtGPA.Text < 3.0)) And (Txtcredit.Value >= 500) And (Txtyears.Value >= 1) _ And ((50 * Txtyears.Value) + Txtcredit.Value >= 650) Then Status = "Conditional Acceptance" Else Status = "We are sorry to inform you that you have been Rejected." End If MsgBox("Full Name: " & Username & Chr(13) & "Mailing Address" & Chr(13) & Address & Chr(13) & City & ", " & State & Chr(13) & Zip & Chr(13) _ & "Admission Status: " & Status, , "preorder Application Status") End Sub 

    End Class

    whenever i start up the program and enter all of my information and it sometimes works and sometimes doesn't giving me this error: System.InvalidCastException: 'Conversion from string "Oklahoma" to type 'Boolean' is not valid.'

    Keep in mind i am very new to any time of programming so i'm not really sure what the error is trying to tell me. Thanks in advance!

    Edit: the messed up line is : ElseIf (txtGPA.Text >= 3.0) And (Txtcredit.Value >= 600) And (Txtyears.Value >= 2) _ And ((50 * Txtyears.Value) + Txtcredit.Value >= 800) And (Liststates.text = "Kansas" Or "Oklahoma" Or "Texas") Then

    submitted by /u/BestestRivenNA
    [link] [comments]

    Can someone point me to the most intelligent Eliza chat bot implementation

    Posted: 25 Mar 2018 04:51 PM PDT

    (C++) Trying to get a second array to print out the same index number as the first one, in order to display years of World Series Championship wins?

    Posted: 25 Mar 2018 04:33 PM PDT

    Long story short, I need this to display the actual years each team won, along with the number of times they won. I have gotten the number of times they have won to run, but I'm struggling with getting the years themselves to print along side this. I created a new file and copied the text from that file to a separate array, but I don't know the next step to take. If anyone has any tips please help. code is below

    https://pastebin.com/0Zz5aaN1

    submitted by /u/2kool4jewschool
    [link] [comments]

    GUI programming ideas

    Posted: 25 Mar 2018 07:57 PM PDT

    My class just wrapped up and we've been programming in C++ since Fall. Our final assignment was an intro to GUIs using QTCreator (we built a calculator). I'm looking for recommendations for GUI apps to build as a somewhat experienced C++ user but new GUI user.

    submitted by /u/zemorah
    [link] [comments]

    Help scraping a json doc from a website?

    Posted: 25 Mar 2018 07:39 PM PDT

    Hi I am trying to scrape the json file in this webpage: http://www.focusfeatures.com/babies

    The json file is found where GlobalsObj.CMS_JSON = {}/

    Thank you in advance for your help.

    I was trying to use scrappy or beautifulsoup but can't figure out this with those tools.

    submitted by /u/hlhelpy
    [link] [comments]

    Custom Vector Class - Multiplication Gives Wrong Results (C++)

    Posted: 25 Mar 2018 12:00 PM PDT

    SOLVED

    So basically, I've had a short course in C++ to introduce OOP concepts. One of the tasks we've been asked to do consists of creating a custom mathematical vector class, where the * operator is overloaded to be able to multiply a scalar by the vector and also calculate cross products in the case of a 3D vector. I have included the header file consisting of the class and the main function I'm using for testing below:

    main.cpp

    #include <iostream> #include <vector> #include "vectorclass.hpp" using namespace std; int main(){ double array1[] = {7, 2, 4}; MathVector vec1(3, array1); double array2[] = {1, 3, 2}; MathVector vec2(3, array2); double i = 1.5; // Test * operator cross product MathVector vec4 = vec1*vec2; cout << "Product of [7, 2, 4] and [1, 3, 2] is [" << vec4[1] << ", " << vec4[2] << ", " << vec4[3] << "]" << endl; // Test * operator product with scalar MathVector vec5 = vec1*i; cout << "Product of [7, 2, 4] and 1.5 is [" << vec5[1] << ", " << vec5[2] << ", " << vec5[3] << "]" << endl; return 0; } 

    vectorclass.hpp

    #ifndef VECTORCLASS_HPP_ #define VECTORCLASS_HPP_ #include <iostream> #include <vector> class MathVector { private: std::vector< double > elements; std::size_t length; public: MathVector() : length(3) { for(int i = 0; i < 4; i++){ elements[i] = 0; } } MathVector(std::size_t _length) : length(_length) { elements.push_back(_length); for(int i = 0; i < _length; i++){ elements[i] = 0;}; } MathVector(std::size_t _length, double array[]) : length(_length) { elements.push_back(_length); for(int i = 0; i < _length; i++){ elements[i] = array[i]; } } MathVector(const MathVector &vector) : length(vector.GetLength()){ elements.push_back(vector.GetLength()); for(int i = 0; i < vector.GetLength(); i++){ elements[i] = vector.GetElement(i); } } std::size_t GetLength() const { return length; } std::vector< double > GetElements() { return elements; } double GetElement(int index) const { return elements[index]; } double &operator[](int index) { return elements[index]; } void operator=(MathVector Vec) { length = Vec.GetLength(); elements = Vec.GetElements(); } MathVector operator*(double number) { double array[length]; for(int i = 0; i < length; i++){ array[i] = number*elements[i]; } MathVector product(length, array); return product; } MathVector operator*(MathVector V) { double e0 = elements[0], e1 = elements[1], e2 = elements[2]; double v0 = V[0], v1 = V[1], v2 = V[2]; double newelement1 = (e1)*(v2) - (e2)*(v1); double newelement2 = (e2)*(v0) - (e0)*(v2); double newelement3 = (e0)*(v1) - (e1)*(v0); double array[] = {newelement1, newelement2, newelement3}; MathVector product(length, array); return product; } }; 
    

    No comments:

    Post a Comment