tinstaafl 1,176 Posting Maven

Here's a free course that also has video transcripts in Chinese

Click Here

learnerya commented: ok,very thanks +0
tinstaafl 1,176 Posting Maven

I would suggest first off is examining exactly what you want to do with your programming. There are a great many areas to explore and most languages excel in only some of those areas. If your interest is as a hobby, you could do far worse than vb.net. Not only is it a robust, plain language coding language it also includes a WYSIWYG gui editor and is very good at learning how to think as a programmer.

tinstaafl 1,176 Posting Maven

Have you tried looking at the answers on this page?

Click Here

Reverend Jim commented: Welcome back. Been a while. +15
tinstaafl 1,176 Posting Maven

What you have is fairly basic. I would suggest making a list of each class the fields/properties and functions, with descriptions and build the the java versions from that. Google becomes your friend here. Use it to look up code to accomplish what needs to be done(i.e. shuffle algorithm).
The main advantage of this is, you learn about java as you work on this and become more grounded in it.

tinstaafl 1,176 Posting Maven

Assuming you want the user to retry and not create a fatal error, I would suggest reading the input as a string, then passing it to a simple verification function:

bool isNumeric(const std::string& input) {
    return std::all_of(input.begin(), input.end(), ::isdigit);
}

I believe you need atleast c++11 for this.

tinstaafl 1,176 Posting Maven

I suspect your problem is here: for ( int i=i; i<=n/2 ; i++). It looks to me that what you want is: for ( int i = 0; i <= n/2 ; i++)

tinstaafl 1,176 Posting Maven

Alternatively you can use the Path environment variable to hold the complete path to dw.exe

tinstaafl 1,176 Posting Maven

The first thing I'd suggest is, use m.Name = "missile", instead of Tag. This allows you to get rid of that loop and access the missile picturebox directly using indexing, PictureBox y = (PictureBox)this.Controls["missile"];

Instead of trying to calculate the trajectory of the missile, you can use the Location property of the player and the enemy to calculate the direction of the missile movement and have it step a portion of the path each time you call MoveMissile. Something like this should work:

    int missileStep { get; } = 10;
    void MoveMissile()
    {
        PictureBox missile = (PictureBox)Controls["missile"];
        int xOffset = (enemy.Location.X - player.Location.X) / missileStep;
        int yOffset = (enemy.Location.Y - player.Location.Y) / missileStep;
        missile.Location = new Point(missile.Location.X + xOffset, missile.Location.Y + yOffset);
        if (missile.Location == enemy.Location)
        {
            Controls.Remove(missile);
        }
    }

missileStep can set to the value which suits you best.

tinstaafl 1,176 Posting Maven

As this is VBA and Microsoft hasn't replaced it yet, I'll try and help. You're not getting the max ID because you're not looping through the rows.

Also you're using the same variable for strings and integers. This is very bad practice and can lead to very hard to find bugs.

Private Function GenID() As String
        Dim dr As OleDbDataReader
        Dim com As OleDbCommand
        Dim StrValue As String = "2021000"
        Dim value As Integer
        Dim ID As String

        Try
            con.Open()
            com = New OleDbCommand("SELECT TOP 1 <studno> FROM record ORDER by <studno> DESC", con)
            dr = com.ExecuteReader(CommandBehavior.CloseConnection)
            While dr.HasRows
                dr.Read()
                value = dr.Item("<studno>")
            End While

            value += 1

            If value <= 9 Then                'Value is between 0 and 10
                StrValue = "202100" & value
            ElseIf value <= 99 Then        'Value is between 9 and 100
                StrValue = "20210" & value
            ElseIf value <= 999 Then        'Value is between 999 and 1000
                StrValue = "2021" & value
            End If

        Catch ex As Exception
            If con.State = ConnectionState.Open Then
                con.Close()
            End If
            StrValue = "2021000"
        End Try

        Return StrValue
End Function

I added another variable to hold the return string and changed the If statement to a While loop. Since I don't have a connection to your database, I can't test this, but I think it will work.

tinstaafl 1,176 Posting Maven

How would you write a function for Collection.sort to do that? It doesn't normally sort by columns.

JamesCherrill commented: Good point, :( +15
tinstaafl 1,176 Posting Maven

Here's a way that is in place, that uses bubble sort.

  public static void sortColumns(ArrayList<ArrayList<Double>> arr){
      int limit = arr.size();
      boolean isSwapped = false;
      for(int col = 0; col < limit; ++col){
          do{
            isSwapped = false;            
            for(int row = 0; row < limit - 1; ++row){
                if(arr.get(row).get(col) > arr.get(row+1).get(col)){
                    swap(arr,row,col,row+1,col);
                    isSwapped = true;
                }
            }
          }while(isSwapped);

      }      
  }
  private static void swap(ArrayList<ArrayList<Double>> arr, int rowA, int colA, int rowB, int colB){
      Double temp = arr.get(rowA).get(colA);
      arr.get(rowA).set(colA,arr.get(rowB).get(colB));
      arr.get(rowB).set(colB, temp);
  }
tinstaafl 1,176 Posting Maven

Not sure if this is what you're looking for, but it seems to work:

(ns Files.myfile)
(require '[clojure.string :as str])
(defn hello-world []
  (println "Hello World"))
 (hello-world)
(def s (map read-string(str/split(slurp "integers.txt") #",")))
  (println s)

the last line in your code seems to be a typo. This post has more info.

tinstaafl 1,176 Posting Maven

The remove code doesn't do anything except get the index.

The insert code overwrites the insertion point instead of inserting into the table.

ComSciNum7 commented: Thank you for your help! Do you know what I could do to re-write the insert method as intended? +0
tinstaafl 1,176 Posting Maven

I think you are confused about what you are using the variable weekday for.

First you declare it as a string.
Then you try to assign a string array to it.
Then you assign the user's input to it.

I would suggest writing out what you want to do before you try and write code to do it.

Muhamad_7 commented: Thank you sir for the comment. +0
tinstaafl 1,176 Posting Maven

Basically this scheme uses variable offsets, but it generates the bytes on the fly. They aren't truly random, but there aren't any obvious patterns and the output passes all the NIST tests.

Since a simple password can be used to do the de/encryption it is much easier to hand off to the recipient and any good password generator can create one.

Since only part of the generated sub keys are used, it becomes very difficult if not impossible to reverse engineer the sub key to find the previous or next sub key.

tinstaafl 1,176 Posting Maven

Yes you'll need to be a little more specific. For instance a small project could be to write "Hello World" to the console.

rproffitt commented: Hello! +15
tinstaafl 1,176 Posting Maven

I think it would be worth your while to check out a modern IDE with syntax checking. Visual Studio Code and Netbeans come to mind. Free and cross platform.

tinstaafl 1,176 Posting Maven

While the code is very sparce, the error message tells you what is wrong. In the namespace AdvoDiary, DataSet is a namespace. I would suggest you look inside DataSet for the type that you want.

tinstaafl 1,176 Posting Maven
tinstaafl 1,176 Posting Maven

It looks to me that you need to get back to basics. Here's a tutorial on c++ functions that should help.

tinstaafl 1,176 Posting Maven

A Form is a class pretty much the same as any other. If you look at the code(press the <> icon in the solution explorer) you shoud see the constructor for form1 already made for you. It is easy to recognize because it has a call to the InitializeComponent method. Put any initialization code you want after the call to that method.

tinstaafl 1,176 Posting Maven

Are you passing the path to the file in this pattern - file://localhost/path/to/table.csv?

tinstaafl 1,176 Posting Maven

According to the documentation, pd.read_table instead of pd.read_csv might work better.

tinstaafl 1,176 Posting Maven

I think perhaps you need to look at the limits of this challenge a little closer. The size of the array(N) is limited to 10⁷. It's the numbers in the array(Aᵢ) that are limited to 10¹⁰.

1 <= T <= 100
1 <= N <= 10⁷
1 <= Aᵢ <= 10¹⁰

tinstaafl 1,176 Posting Maven

The return is outside the if block but inside the for block as this formatted code shows:

int findmaxindex(int a[],int start,int end){
    int i,currmaxindex=start;
    for(i=start;i<end;i++){
        if(a[i]>=a[currmaxindex]){
            currmaxindex=i;
        }
        return currmaxindex;
    }
}

The if block has nothing to do with the error

tinstaafl 1,176 Posting Maven

Actually to me it looks like the problem is the return on line 27, is controlled by the for block. Since it's possible for the control to bypass the for block(i.e. if start == end) the return could be missed.

I think what you're looking for is something like this:

int findmaxindex(int a[],int start,int end){
    int i,currmaxindex=start;
    for(i=start;i<end;i++){
        if(a[i]>=a[currmaxindex]){
            currmaxindex=i;
        }
    }
    return currmaxindex;
}
tinstaafl 1,176 Posting Maven

One way to think about it. A 2D array is basically an array of arrays. In the same way that an array of integers when passed to a function doesn't need the size itemized, it just needs to know what is contained in the array, a bunch of integers,of which the size of each integer is known , the 2D array doesn't need the size itemized it just needs to know what is in the array, a bunch of arrays , of which the size isn't known so it has to be supplied.

Hope this helps.

tinstaafl 1,176 Posting Maven

What is your code supposed to do?

What is your doing or not doing that's wrong?

What if any error messages is the compiler reporting back to you?

This is the bare minimum that is needed for someone to help you.

tinstaafl 1,176 Posting Maven

How are you storing the values?

What code are you having trouble with?

tinstaafl 1,176 Posting Maven

Did some more research on this. It appears the tutorial was written using python 3.4. The syntax warning is new with python 3.8. I would suggest that this is why the tutorial doesn't show a warning.

davidmoffitt1 commented: Thank you very much!! +1
tinstaafl 1,176 Posting Maven

One thing to remember is that in python formatting matters. This site has a code editor to help you format your code. The button is titled Code Block and looks like this, </>.

def get_gender(sex='unknown'):
    if sex is "m":
        sex = 'Male'
    elif sex is 'f':
        sex = 'Female'
    print(sex)
get_gender('m')
get_gender('f')
get_gender()

That being said, do you have the link to the tutorial?

This code will always give you that warning. Basically:

is is for comparing whether 2 objects reference the same area in memory.

== is for comparing whether 2 objects hold the same value(s)

tinstaafl 1,176 Posting Maven

Have you tried the tutorials code verbatim?

Can you show the code in question?

tinstaafl 1,176 Posting Maven

I think you'll have to explain more about what exactly the code is supposed to do. The second line, unsigned int arr2 = (unsigned int ) arr1;, should throw a compiler error, since casting a pointer to an unsigned int can result in loss of information.

tinstaafl 1,176 Posting Maven

@bluenunn - If you want to add to an existing post that is obviously dead, it is better to add a new question and reference the old one in the question.

That being said, what is the bug? e is not at the beginning or the end of the string. Why would you expect strip to remove it? I think perhaps you might need to read the docs again or follow a tutorial on the subject.

If, however, you want the whitespace and the e stripped, you can use this, world.strip('e ')

tinstaafl 1,176 Posting Maven

The while loop will need the same parts that are part of the for loop. Counter, limit,incrementing. In a while loop the limit is included in the statement. The counter is initialized before the statement and the incrementing is done inside the block. As an example:

    //counter
    int i = 0;
    //limit
    while( i<strlen(t))
    {
        for(int k = 0;k<=7 ;k++)
        {
            if(t[i] == marks[k])
                t[i] = ' ';
        }
        //incrementing
        ++i;
    }  
   return t;
}
Katara1 commented: THANK YOU ! +0
tinstaafl 1,176 Posting Maven

One good getting started resource is Get started with Visual Studio. This page has videos for beginners as well as links to more specific tutorials. One of the first things you'll have to decide, is which language(s) you'll be focused on first. At present there are about 5 different ones supported inside Visual Studio.

rproffitt commented: More choices than a Spotify playlist. +15
tinstaafl 1,176 Posting Maven

Your code doesn't allow for any of the correct values except 180. If you want values inside that range you have to think about excluding the ones outside that range. something like this,
while (mark < 0 || mark > 180), wil allow all the marks from 0 to 180.

tinstaafl 1,176 Posting Maven

What I've noticed in your code, is basically exactly as the error message you get. You're using variables before you've given them values.

The first one is a little tricky. You're accessing menuArray to print out MenuItems, but you haven't given any of the members of MenuItems any values.

In the second. You're passing number to makeSelection without giving it a value. I also noted that this one is largely redundant. You're passing this variable by value but you aren't using the value. I think that you can eliminate that parameter and just create number inside makeSelection.

tinstaafl 1,176 Posting Maven

c1 and c2 are variable not controls. You can't look up their names in the control collection. I would suggest you research using Reflection.

himanshucary commented: ..Actually I am new to the vb.net. I don't know how to use "reflection" in this programm. Can you please. give me an example to solve my problem. +0
tinstaafl 1,176 Posting Maven

I find if you use a good modern IDE(Visual Studio, Visual Code, NetBeans, etc.), debugging is automatic and very easy to use

tinstaafl 1,176 Posting Maven

It appears to me that you have the wrong idea about what a copy constructor is supposed to be doing. The present LinkedList should be constructed by copying the values in the passed LinkedList. In this instance head should start off as a new ListNode and the loop should iterate over copy to add the values to head. You currently have it the other way around

tinstaafl 1,176 Posting Maven

Instead of expecting someone to pour over almost 500 lines of code, how about showing where your counter is being used.

tinstaafl 1,176 Posting Maven

It's hard to see how to help you without seeing the code you've got, including what you've tried for your save function.

tinstaafl 1,176 Posting Maven

It looks to me that you're adding the SubItem to a new LitViewItem instead of an existing one. By stepping through the array by 2, you can add the SubItem to the existing ListViewItem. I haven't been abble to test this, but, something like this should work:

for (int i = 0; i < strarr.Length; i += 2)
{
        ListViewItem item = new ListViewItem();
        item.Text = strarr[i];
        item.SubItems.Add(strarr[i+1]);
        listView1.Items.Add(item);            
}

On a side note, if I'm not mistaken, the ListView.Add method returns a ListViewItem, so you can chain the SubItem.Add on to the ListView.Add.

tinstaafl 1,176 Posting Maven

It's hard to say for sure where the problem is since the code you submitted won't compile. However, one place to start is in the declaration for inputFile. In accountInfo you declare it as ifstream but in deposit and withdraw you declare it as fstream.

On a side note, any time you see duplication in the code you're writing, breaking that out into a separate function, helps to eliminate these kinds of inconsistencies.

codiene bryant commented: The code wont compile? +0
tinstaafl 1,176 Posting Maven

Does strarr have the proper elements?
Does ReadZombieTxt return the proper string?
What does Zombie.txt look like?

Answer these questions and it'll be easier to get help.

tinstaafl 1,176 Posting Maven

Something else to consider. You've declared FieldName as 15 strings with the longest at 14 characters. In reality you have 14 strings with the longest at 15 characters. Simply reversing the limits of the array would have fixed the problem. Or, better yet use a simple string array string FieldName[14]

tinstaafl 1,176 Posting Maven

Another way to go is to make form2 a dialog form. This will make it modal and since it remains part of form1, form1 will still be on top but inaccessible while form2 is active.

SoftBa commented: Reading about codes I run into Dialog and Modal forms in VB. Thanks. +2
tinstaafl 1,176 Posting Maven

A free Google account includes 5GB of space, that you can use through Google Drive. It will even integrate with a Windows Desktop.

tinstaafl 1,176 Posting Maven

The answer to your original problem is fairly simple. The comparator that you pass to sort must promote weak ordering. By comparing using <= you're promotiong strong ordering and this makes the compiler fail. Removing the = fixes it.