printf()打印错误的值

时间:2019-10-13 20:22:17

标签: c printf arithmetic-expressions

这是我的完整代码,每当我运行它时,它都会打印随机的负值,不知道出了什么问题。 使用Ubuntu运行并运行“ gcc -Wall -Wextra test.c”

LogisticRegression

1 个答案:

答案 0 :(得分:8)

您正在传递 import java.util.Scanner; import java.lang.Math; class Lesson_20_Activity { public static void main(String[] args) { Scanner scan = new Scanner(System.in); double lat=0; double lon=0; int num = 1; //min variables double xlat=Integer.MAX_VALUE; double xlon=Integer.MAX_VALUE; //max variables double ylat=Integer.MIN_VALUE; double ylon=Integer.MIN_VALUE; /* the program wants the greatest and lowest values entered in latitude longitude. */ while (num == 1){ System.out.println("Please enter the latitude: "); lat = scan.nextDouble(); //establishes the largest input if(lat>-90&&lat<90&&lat>ylat){ ylat=lat; } //establishes the smallest input if(lat>-90&&lat<90&&lat<xlat){ xlat=lat; } System.out.println("Please enter the longitude: "); lon = scan.nextDouble(); //establishes the largest input if(lon>-180&&lon<180&&lon>ylon){ ylon=lon; } //establishes the smallest input if(lon>-180&&lon<180&&lon<xlon){ xlon=lon; } System.out.println("Would you like to enter another location?"); num = scan.nextInt(); } System.out.println("Farthest North: " + ylat); System.out.println("Farthest South: " + xlat); System.out.println("Farthest East: " + ylon); System.out.println("Farthest West: " + xlon); } } 的地址。您需要传递值。

import sys
import re
#The input of the file needs to take the maximum size of the queue
#The input needs to choose a maximum number of states or depth
#The input needs to choose the set of dominoes

maxQueueSize = 0
maxStates = 0
outPutToken = 0;
numberOfDominoes = 0
dominoesFile = 0

def remove(list):
    pattern =r'[0-9]\n'
    list = [re.sub(pattern, '', i) for i in list]
    return list

def input_words(file_name):
    f = open(file_name, 'r')
    f = f.readlines()
    j = 0
    maxQueueSize = f[0]
    maxStates = f[1]
    outPutToken = bool(f[2])
    numberOfDominoes = f[3]
    dominoesFile = f[4: 7]
    for i in dominoesFile:
        dominesFile = remove(dominoesFile)
        #dominoesFile[j] = i.split()
        j+=1
    print(dominoesFile)

if __name__ == '__main__':
    input_words(sys.argv[1])
#    print(maxQueueSize)
else :
    print("Please enter a file!")

class Domino:
    def __init__(self, top, bottom):
        self.top = ""
        self.bottom = ""

有了它,您的代码将打印p的地址,无论发生什么情况。

此外,由于您使用的是printf("%d\n", p); ,因此您可能希望使用由%d 插入的%u 格式化程序。