小编Pau*_*ar.的帖子

在Haskell中t0,t1,t2和a0是什么意思?

我已经在Haskell编写了几个星期的代码,我一直看到t0,t1,t2和a0的错误.我想知道,他们有什么特别的意义,或者他们只是变量吗?我在问,因为我想更好地理解编译器向我吐出的错误.

haskell ghci

8
推荐指数
1
解决办法
2316
查看次数

有人可以用简单的词语解释呼叫/ cc吗?

我正在研究语言球拍,并试图掌握什么叫/ cc实际上是为了.有人可以用简单的语言解释一下,举一两个例子吗?谢谢.

racket

8
推荐指数
2
解决办法
2904
查看次数

MIPS中的时钟实现

尊敬的所有Stackoverflow用户,我正在尝试在MIPS中编写将实现时钟的代码。我正在构造自己的异常处理程序,并且做错了什么,因为当前我仅显示00:00。因此,我使用标志来确定是否是时间中断,但是该标志从未设置为1,所以我不明白为什么不这样做。如果有人看到我的错误或对我的概念有很大的误解,请告诉我。

这是我的代码:

    .globl __eoth
__eoth:
    .globl Yesdisplay    #flag to indicate if a second passed

Yesdisplay:  .word 0
.data

next:
    .asciiz "\n"

    .text
    .globl __start
__start:
    li   $t2, 0
    li   $s8, 1
    li   $s7, 1
    li   $s6, 0
    li   $s4, 0
    li   $s5, 4
    li   $t5, 0
    li   $t6, 10
    li   $t7, 1
    li   $v0, 4
    li   $s3, 8
#################################################################
#Set my coprocessor register $11 to 100 so it will give a second#
#################################################################
    li   $s6, 100
    mtc0 $s6, $11
    #li …
Run Code Online (Sandbox Code Playgroud)

assembly kernel mips

5
推荐指数
0
解决办法
3574
查看次数

在秋千中调整图像大小

我有一段代码,我正在使用它来调整图像大小到窗帘大小(我想将分辨率更改为200 dpi).基本上我需要它的原因是因为我想显示用户选择的图像(有点大)然后如果用户批准我想在不同的地方显示相同的图像但使用较小的分辨率.不幸的是,如果我给它一个大图像,屏幕上就不会显示任何内容.另外,如果我改变了

imageLabel.setIcon(newIcon); 
Run Code Online (Sandbox Code Playgroud)

imageLabel.setIcon(icon); 
Run Code Online (Sandbox Code Playgroud)

我得到的图像显示但没有正确的分辨率,我知道我在这段代码中有问题而不是其他地方.

Image img = icon.getImage();

BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.createGraphics();
boolean myBool = g.drawImage(img, 0, 0, 100, 100, null);
System.out.println(myBool);
ImageIcon newIcon = new ImageIcon(bi);
imageLabel.setIcon(newIcon);
submitText.setText(currentImagePath);
imageThirdPanel.add(imageLabel);
Run Code Online (Sandbox Code Playgroud)

java graphics swing bufferedimage imageicon

5
推荐指数
2
解决办法
1万
查看次数

检测到glibc,realloc():指针无效

我为冗长的代码道歉.我有一个简单的问题,但我认为我包含了我的代码,所以我很清楚我来自哪里.我得到了realloc腐败.我认为腐败是因为我没有正确解放.实际上,我不确定glibc甚至说什么或意味着什么.任何人都能简单地向我解释一下吗?再次抱歉冗长的代码.


#include "draw2.h"
#include "draw2a.h"
#include "draw2b.h"

const char Exec_c[]  = "java -jar Sketchpad.jar";

void parseFile(FILE * fp, FILE *sketcher){ 
    char line [MAX_WORD] = {"NULL"}; 
    char word [MAX_WORD] = {"NULL"};
    char figureName [MAX_WORD] = {"NULL"};
    struct figure *pointsAndname;                     
    long int countNumberoffigures = 0;
    printOutput();
    long int temp = 10;
    pointsAndname = malloc(temp * sizeof(struct figure));
    assert(pointsAndname != NULL);
    while ( fgets(line, MAX_WORD - 1, fp) != NULL ){
        int nuRead = sscanf(line, "%s", word);
        assert(pointsAndname != NULL);
        if ( nuRead …
Run Code Online (Sandbox Code Playgroud)

c malloc free glibc realloc

4
推荐指数
1
解决办法
1万
查看次数

JCalendar中使用JDateChooser的不需要的数据

我正在使用JDateChooser JCalendar(使用Swing).我正在尝试获得"yyyy-MM-dd"的格式,但由于某种原因我也得到时间而且它总是相同的(00:00:00 MDT).任何人都知道如何摆脱时间?提前致谢.

try {
    calendarDate = new JDateChooser();
} catch (Exception e) {
    e.printStackTrace();
}
calendarDate.setDateFormatString("yyyy-MM-dd");

dateLabel = new JLabel("Date");
parent.frame2.getContentPane().add(dateLabel);//1
parent.frame2.getContentPane().add(calendarDate);   
Run Code Online (Sandbox Code Playgroud)

java swing jcalendar jdatechooser

4
推荐指数
1
解决办法
7682
查看次数

使用Java 1.6中的Swing库构建一个简单的GUI

我正在尝试使用Swing库构建一个简单的GUI.我不明白为什么我的表正在删除之前添加到GUI的所有内容,然后才创建表.我假设它是addMainPanel中的某个命令,但我不确定是哪个.非常感谢您的建议.

package fuelConsumption;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class LogView implements ActionListener {

    private Log myLog;
    private JFrame frame;

    public LogView (String frameName) {
        this.frame = new JFrame(frameName);
        this.frame.setPreferredSize(new Dimension(500,500));
        this.frame.getContentPane().setLayout(new BorderLayout());

        this.addMainPanel(frame);
        this.addTable(frame);
        //addMenu(frame);
        //addToolBar(frame);

        this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.frame.pack();
        this.frame.setVisible(true);
    }

    private void addTable(JFrame frame2) {
        String[] columnNames = {"date",
                               "station",
                               "fuel grade",
                               "fuel amount",
                               "fuel unit cost",
                               "fuel cost",
                               "trip distance"};
        Object[][] data = {
            {"Shell", 89, 40, 109.5, "bla", …
Run Code Online (Sandbox Code Playgroud)

java layout swing

3
推荐指数
1
解决办法
2073
查看次数

从Java System.in发出读取输入

我正在尝试编写一个方法,提示用户在命令行上输入并从stdin读取其输入为String并返回.第一次调用它时,一切正常.之后对getInput()的所有调用都不会返回任何内容.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Prompts the user for input and reads from standard input (stdin).
 * Note: Always check if the return is null!
 * 
 * @param description Describes the user input.
 * @return A String of the input, or null when failed.
 */
private String getInput(String description)
{       
    System.out.print(description + ": ");
    String input = null;

    InputStreamReader stream = null;
    BufferedReader reader = null;
    try {
        // Open a stream to stdin
        stream = …
Run Code Online (Sandbox Code Playgroud)

java io

2
推荐指数
1
解决办法
4492
查看次数

用户选择了哪一行

如何在JTable中选择哪一行(对我来说并不重要).我希望能够编辑用户选择的行.

我将不胜感激任何帮助.

谢谢.

java swing jtable

2
推荐指数
1
解决办法
86
查看次数

realloc里面的realloc

在C中,你可以在realloc里面重新分配吗?例如,当您需要对它们两者进行malloc并重新分配它们时,结构中的结构.如果是,有人可以提供一个简单的例子吗?先感谢您.

c malloc struct realloc

1
推荐指数
1
解决办法
720
查看次数

改变了撰写功能

我现在想知道什么是f.有人可以举例说明我应该如何运行这个功能?(注意:我明白(.)是函数组合,我知道函数组成是什么)

-- compose a function n >= 0 times with itself
composeN :: Int -> (a -> a) -> (a -> a)
composeN 0 f = id
composeN n f = f . (composeN (n-1) f)
Run Code Online (Sandbox Code Playgroud)

haskell ghci

1
推荐指数
1
解决办法
72
查看次数

Haskell类型导致"输入中的解析错误:'"

最后三行产生错误.如何在不出错的情况下获取这些表达式的类型?谢谢,麻烦您了.

--
-- pairs of Int
--

data Pair = P Int Int deriving (Show, Eq)

pairFst (P x y ) = x
pairSnd (P x y ) = y

instance Ord Pair where
  compare (P x1 y1) (P x2 y2) = 
    case compare x1 x2 of EQ -> compare y1 y2
                          LT -> LT
                          GT -> GT
--
-- pairs of things of type a
--

data Pair a = P a a deriving (Show, Eq)

pairFst (P x …
Run Code Online (Sandbox Code Playgroud)

haskell functional-programming

0
推荐指数
1
解决办法
811
查看次数