while-loop

Average, max, and min program in C

我与影子孤独终老i 提交于 2019-12-20 02:11:53
问题 So I'm coding in C, and I need to come up with code that will take n numbers from the user, and find their minimum, maximum, average, and sum of squares for for their values. So far I have the average and sum of squares portion, but the minimum and maximum is biting me. Keep in mind I'm at a very rudimentary level, and I have not reached arrays yet. All I know are logical operators, functions, loops, and the use of the stdlib.h, math.h, and stdio.h libraries. This is what I have so far. The

Average, max, and min program in C

感情迁移 提交于 2019-12-20 02:11:53
问题 So I'm coding in C, and I need to come up with code that will take n numbers from the user, and find their minimum, maximum, average, and sum of squares for for their values. So far I have the average and sum of squares portion, but the minimum and maximum is biting me. Keep in mind I'm at a very rudimentary level, and I have not reached arrays yet. All I know are logical operators, functions, loops, and the use of the stdlib.h, math.h, and stdio.h libraries. This is what I have so far. The

Bash loop to compare files

烂漫一生 提交于 2019-12-19 21:27:01
问题 I'm obviously missing something simply, and know the problem is that it's creating a blank output which is why it can't compare. However if someone could shed some light on this it would be great - I haven't isolated it. Ultimately, I'm trying to compare the md5sum from a list stored in a txt file, to that stored on the server. If errors, I need it to report that. Here's the output: root@vps [~/testinggrounds]# cat md5.txt | while read a b; do > md5sum "$b" | read c d > if [ "$a" != "$c" ] ;

Python&PyGTK: Stop while on button click

浪子不回头ぞ 提交于 2019-12-19 21:24:18
问题 I'm working on programming some application and I would like to create while loop when button is clicked and if it's clicked again to stop it. This is the code for button: self.btnThisOne = gtk.Button("This one") self.btnThisOne.connect("clicked", self.startLoop) The code for startLoop def would be: def startLoop(self): while self.btnThisOne?(is_clicked)?: #do something How to do that? 回答1: Unfortunately, you cannot just have an unconstrained while loop running in the main thread of your

Breaking nested loop and main loop [duplicate]

帅比萌擦擦* 提交于 2019-12-19 16:57:59
问题 This question already has answers here : How do I break out of nested loops in Java? (35 answers) Closed 6 years ago . I have the following code: int x = 100; //Or some other value while(x > 0) { for(int i = 5; i > 0; i++) { x = x-2; if(x == 0) break; } } However, this will only break the for loop. How can I have it so that it breaks both the for and the while loops? Cheers! 回答1: You can use a labeled break, which redirects the execution to after the block marked by the label: OUTER: while(x

Continue executing loop after catching an exception in try/catch

徘徊边缘 提交于 2019-12-19 16:48:12
问题 Once an exception is caught in this code, the menuSystem method is run, but once I go to input a number the programme closes and the "Build is successful" message is displayed. Is there any way to get back into the while loop once an exception has occured? public static void main(String[] args) { final UnitResults myUnit = new UnitResults(10, "Java"); int option = menuSystem(); try { while (option != 0) { final Scanner keyb = new Scanner(System.in); System.out.println(""); switch (option) { }

While read line, awk $line

会有一股神秘感。 提交于 2019-12-19 11:58:08
问题 I have a file that contains a list of numbers. I have a second file with various entries and several fields each. What I want to do is to get all the lines whose 12th field is equal to the 1st number and place them in a new file, then to the second number, and so on. I wrote a one-liner that makes sense, but I can't figure out why it won't work. This is the list of numbers: cat truncations_list.txt 3 318 407 412 7 The file with the entries to be sorted is: M00970:45:000000000-A42FD:1:1101

C Concatenate string in while loop

拟墨画扇 提交于 2019-12-19 11:52:43
问题 I'm trying to concatenate part of a struct with hex values. I run over every byte in the loop and convert to hex, then I want to concatenate all the hex into one long string. However, I only end up with one value at the end of the loop. For some reason the string isnt concatenating properly. Any idea what Im doing wrong? typedef struct OPTIONS_STR { int max; int printName; } OPTIONS; void set_default_options(OPTIONS *options) { options->max = -1; options->printName = 0; } void do_file(FILE

Behaviour of scanf when newline is in the format string

北城以北 提交于 2019-12-19 10:14:22
问题 Below is the copy of my code. Basically, I need to create a program that calculates pay based on "paycodes" eg the worker's position. I've created my switch statement and everything works except for the very beginning when I'm entering the first paycode. I enter the first paycode, it goes to the next line, leaving it blank. I put in another number, and it runs that number and the previous number the way it is supposed to. Then, after that everything works fine. I'm sure it's a simple solution

Mysql fetch array, table results

元气小坏坏 提交于 2019-12-19 10:03:11
问题 i'm pretty new to this and not sure how should i do it, I've got a database with a column called "names" how can i make it display in so? <tr> <td width="270px">Henry</td> <td width="270px">Jeffrey</td> <td width="270px">Hansel</td> </tr> <tr> <td width="270px">Michelle</td> <td width="270px">Jackson</td> <td width="270px">Ivan</td> </tr> I only know how i should do it if the records goes one after another vertically. $result = mysql_query('SELECT * FROM member'); while($row = mysql_fetch