while-loop

c wait for stdin read?

删除回忆录丶 提交于 2019-12-14 04:26:22
问题 in my application, i'm trying to achieve something like this: i have: data 0, data 1, data 2, ... data n. some parameters to pass flow: starts the program with some parameters and write data 0 into stdin the program does calculation according to the passed data "data 0" and parameters "wait" for new stdin and (clear old stdin,buffer and variables?) repeat 1 ~2 when i put data 1, data 2... and so on when reaches data n, terminate(or if i input a abort code to stdin telling the program to

Finding last row with while loop in excel

☆樱花仙子☆ 提交于 2019-12-14 04:13:04
问题 I want to find the last row with text in column A of an excel spreadsheet using a while loop. I'm not sure as to the exact syntax that I need, since I'm new to VBA. I realize there are other ways to find the last row, however I need to use a while loop starting at row 20. Dim Row As Integer Row = 20 Do While .Range("A" & Row) <> "" Row = Row + 1 Loop 回答1: Your code will only find the first empty cell in that column, which is not necessarily after the last used row. Why must it be a "While"

How optimize while in while code? [duplicate]

荒凉一梦 提交于 2019-12-14 04:13:04
问题 This question already has an answer here : Optimize while and SQL in foreach (1 answer) Closed 5 years ago . My code is : $text = '12-10-4-32-45-name-sara-x-y-86'; $array = explode('-',$text); foreach($array as $value) { $sql = mysql_query("SELECT * FROM `table` WHERE `pid`='$value' ORDER BY `id` LIMIT 3"); while($row = mysql_fetch_array($sql)) { echo $row['title']; echo ''; } echo ''; } This code work full but if in $text use 150 variable , server down ! How optimize this code for most

Ending a loop once the user is wrong twice?

ぐ巨炮叔叔 提交于 2019-12-14 04:01:36
问题 I am doing a quiz and testing the user. If the user is wrong he is allowed a second chance or skip, if he chooses 2nd chance and is wrong again, the game is over. How do I break out of this loop to end the game? I tried a do while loop, do { stuff} while (wrong<2) while counting ++wrong; every time he's wrong, but didnt work. I have labeled the ++wrong with // statements below void player_try (string questions[][5], char answers[]) { char user_guess; int m = 0; srand(time(NULL)); int x; int

While loop creating

好久不见. 提交于 2019-12-14 03:32:21
问题 I am writing a program in Python that defines a function that takes a single argument. The function has to be a while loop the returns the largest power of 16 that it is equal to. However, I am not sure how to write the while loop. 回答1: Python Docs while True: n = input("Please enter 'hello':") if n.strip() == 'hello': break so, in layman's terms while <condition>: ... 回答2: I couldn't completely understand your question but here's how to do a while loop to get the x to the 16th power of an

Why is this while loop looping infinitely? [closed]

本秂侑毒 提交于 2019-12-14 03:32:20
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . So i'm making a web app for my studies, it basically uses a combination of Twitter's streaming api and Google Maps to display the Lat Lng values. Y is an element which states the number of tweets which have been received, ( checks length of an array) and X is another which has it's text content incremented by 1

where to initiate object in java

岁酱吖の 提交于 2019-12-14 03:31:40
问题 This question relates to my answer of another of my question. The original question is here Can anyone explain why the bad code fails in the way explained in the comments (by the wy it is in pseudo code) // bad code ResultSet rs = getDataFromDBMS("Select * from [tableName];"); //temp uses a collection member within it to hold a list of column names to data value pairs (hashmap<String,String>) Object temp = new objectToHoldInfoFromResultSet(); // loop over the result set while (rs.next)// for

Loop through global substitution

守給你的承諾、 提交于 2019-12-14 03:22:32
问题 $num = 6; $str = "1 2 3 4"; while ($str =~ s/\d/$num/g) { print $str, "\n"; $num++; } Is it possible to do something like the above in perl? I would like the loop to run only 4 times and to finish with $str being 6 7 8 9 . 回答1: You don't need the loop: the /g modifier causes the substitution to be repeated as many times as it matches. What you want is the /e modifier to compute the substitution. Assuming the effect you were after is to add 5 to each number, the example code is as follows.

php - get meta value by using meta key from mysql

纵然是瞬间 提交于 2019-12-14 03:18:55
问题 I have a query like SELECT * FROM membermetas WHERE memberId =15 Table image : and my php code is $memberMetaQuery = "select * from membermetas where memberId='$id'"; $getMemberMeta = mysql_query($memberMetaQuery); $memberMetaRow = mysql_fetch_array($getMemberMeta); when i use " echo $memberMetaRow['memberMeta'] " without while loop, it turns the last row. For example: i would like to use only the row " eposta " and its value " mail@mymail.com " is there any selector for this? I think that,

What's the difference between (reader.ready()) and using a for loop to read through a file? [closed]

余生颓废 提交于 2019-12-14 03:00:47
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . In my previous question, I asked about a problem with looping through a file, and solved it. However, I realised that the method failed to read the last set of lines/record. So I changed the original for loop to