Input numbers until -1 is inputed

Input numbers until -1 is inputed

By : user2954229
Date : November 22 2020, 01:01 AM
I think the issue was by ths following , The problem is that after a complete line has been entered n is never reset to a default value and still contains -1. On the next iteration this causes the inner while loop to be skipped and temp.front() to be called on an empty vector, which is undefined behavior. The following updates should get you back on track.
code :
    vector<int> temp;
    n = 0; // RESET n to a default value

    // Add additional check just to be sure.
    if(temp.size() == 0 || temp.front()== -1)


Share : facebook icon twitter icon
How to display the numbers inputed in a text field?

How to display the numbers inputed in a text field?

By : user45547
Date : March 29 2020, 07:55 AM
should help you out I am creating a form with one field to input numbers . How can I show the value of the numbers in text format in the below text field ? , here you are
code :
function readable_number(num){
    var bits_a = ["thousand", "million", "billion", "trillion", "zillion"];
    var bits_b = ["ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"];
    var bits_c = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"];

    if (num==0){return 'zero';}

    var result = (num<0)?'minus ':'';

    num = Math.abs(num);
    for(var i=bits_a.lenght; i>0; i--){
        var p = pow(1000, i);
        if (num > p){
            var b = Math.floor(num/p);
            num -= p * b;
            result += readable_number(b) + ' ' + bits_a[i-1];
            result += ((num)?', ':'');
    if (num > 100){
        var b = Math.floor(num/100);
        num -= 100 * b;
        result += readable_number(b) + ' hundred' + ((num)?' and ':' ');
    if (num >= 20){
        var b = Math.floor(num/10);
        num -= 10 * b;
        result += bits_b[b-1] + ' ';
    if (num){
        result += bits_c[num-1];
    return result;

calculate inputed numbers from textboxes

calculate inputed numbers from textboxes

By : Warattaya Hooya
Date : March 29 2020, 07:55 AM
like below fixes the issue My mission to my program is when a record filtered in the textboxes if i change the numbers it will automatically change the total and calculate in the (total)textbox...can anyone help me whats wrong with my code? I porposely dont loop the textboxes because i have plans on it. , use this on onchange event
code :
 function optTotal() {
        var a1 = document.forms[0].optA;
        var b1 = document.forms[0].optB;
        var c1 = document.forms[0].optC;
        var d1 = document.forms[0].optD;
        if (a1.value && a1.value != "")
            a1 = parseFloat(a1.value);
            a1 = 0;

        if (b1.value && b1.value != "")
            b1 = parseFloat(b1.value);
            b1 = 0;

        if (c1.value && c1.value != "")
            c1 = parseFloat(c1.value);
            c1 = 0;

        if (d1.value && d1.value != "")
            d1 = parseFloat(d1.value);
            d1 = 0;

        var total = a1 + b1 + c1+d1;
        document.forms[0].total.value = total;
How to add inputed numbers in string.(Python)

How to add inputed numbers in string.(Python)

By : Sumathi Kotthuri
Date : March 29 2020, 07:55 AM
With these it helps You're close, you just need to split the string on spaces. Splitting will produce the list of strings ['-5', '5', '3', '5']. Then you can do the rest of the map and sum as you intended.
code :
>>> s = '-5 5 3 5'
>>> sum(map(int, s.split()))
using array print numbers inputed by user ignore duplicate numbers

using array print numbers inputed by user ignore duplicate numbers

By : dieler
Date : March 29 2020, 07:55 AM
Hope this helps What about a write a function to check whether we are going to print the number or not? So that you don't need to sort the inputted array. Moreover, no builtin methods are used.
code :
import static java.lang.System.*;
import java.util.*;

public class Uni {
    public static boolean isContain(int[] src, int end, int value) {
        int start;
        for (start = 0; start < end; start++) {
            if (src[start] == value) {
                return true;
        return false;
    public static void main(String[] args) {
        Scanner sc = new Scanner(in);
        int[] a = new int[5];
        for (int i = 0; i < a.length; i++) {
            out.println("Please type a number");
            a[i] = sc.nextInt();

        for (int i = 0; i < a.length; i++) {
            if (i == 0) {
                out.print(a[i] + " ");
            } else {
                if (!isContain(a, i, a[i])) {
                    out.print(a[i] + " ");
how do I find the max of inputed numbers

how do I find the max of inputed numbers

By : Katie McAuliffe
Date : March 29 2020, 07:55 AM
wish of those help You can either put them all into a list and then run max() on the list, or (if you don't need the list for anything else) simply maintain your own maximum with something like:
Related Posts Related Posts :
  • C++: How to overload pow for user type?
  • C++ using arrays as multidimensional despite initalising it as 1D with pointer
  • How negate std::is_integral for use in tag dispatch?
  • Retrieve serial number from USB memory (Windows environment c++)
  • g++ error: invalid preprocessing directive #INCLUDE
  • C++ What is the std::for_each() function parameter type?
  • C++: Read individual lines from text file, sort words alphabetically
  • Saving 'this' address into a variable
  • c++ command line arguments in ubuntu terminal
  • Convert "Cartesian coordinates" to "polar coordinates with respect to user specified origin"
  • In what order are local scoped objects destructed?
  • How to use SDL_MapRGB with SDL 2.0
  • how compiler and interpreter work in case of array declaration
  • GSL integration behaves strange
  • Cropping an image with OpenCV and C
  • Find the last line in text file and select the first 10 char and print to a new file?
  • Created many CCSprits but when triggering ccTouchBegan gives the last one allways
  • seekp and seekg don't work with fstream
  • Taking input in Sublime Text 3
  • ld: -bind_at_load and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
  • C++ storing #define as std::string would give size as zero compile time
  • How to use static linking with OpenSSL in C/C++
  • What is the difference between a trap, an error, a failure and program abortion?
  • Dynamic members allocation in qt
  • How to reduce object file size when compiling for VxWorks 5.5.1?
  • Printing char by integer qualifier
  • How to write code to be executed before main() gets control?
  • Blocking socket - waitForReadyRead()
  • std::string related errors and handling them, c++
  • VM interpreter - weighting performance benefits and drawbacks of larger instruction set / dispatch loop
  • C / C++ SHIFT / OFFSET / MOVE a Bitmap to the LEFT or RIGHT?
  • Printing numbers column by column
  • How do you change your app icon in visual studio 2013?
  • Fast Screen Transfer
  • c++ Read text file and input the numbers into a 2D array
  • Why are my C++ pointers suddenly diverging?
  • Is there a macro-based adapter to make a functor from a class?
  • CRTP and multilevel inheritance
  • How to implement timer for each object in c++?
  • Stuck when testing custom list class in c++
  • Using each member of class within one function to calculate average
  • check whether if two squares are intersecting with each other
  • Glm Quaternion lookat function
  • Is there guarantee heap allocated block address will not change(implicitly)?
  • Cosine Calculation without cmath library
  • Manually deleting a pointer returned by function
  • Avoid output interleaving
  • C++ error : Expected an identifier
  • Segmentation fault when I call operator new in linux mint
  • Recursively Solving A Sudoku Puzzle Using Backtracking Theoretically
  • lambda closure type and default argument in function template
  • How to ensure the function return consistent floating point values in C/C++?
  • What does throw do when not in used with try and catch?
  • The Unpredictablilty of the Order of Evaluation of Subexpressions
  • cannot convert const wchar_t to 'const_char' for argument 2 in MessageBOX etc etc
  • Size of a empty Class & Derived Virtual Class
  • unformatted i/o to and from memory
  • Storing an std::thread object as a class member
  • Remove duplicate string in an array
  • How to use copy_if() polymorphically?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org