小编Chr*_*tin的帖子

可惜的任务,但我无法解决它

我是一个真正的一级忍者,想要解决我的作业,但我不能这样做:

所以任务是:

说一个介于1-100之间的数字:
我说15个
Okey,这很好
说1-100之间的数字:
我说231
Grrr,不好回答,说另一个数字
我说-58
Grrr,不好回答,说另一个数字
78
Okey,那是好在
1-100之间说一个数字:

这是我的问题,因为我可以在第一行编写代码,但我无法前进

我的代码是:

x=input("Saying a number between 1-100: ")
print(x)
Run Code Online (Sandbox Code Playgroud)

python

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

如果我运行这个程序,即使我将输入设为0,它还是计算得到它的值?

#include<stdio.h>
#include<conio.h>
#include<malloc.h>

void main()
{
    struct node
    {
        int data;
        struct node *next;
    };
    struct node *head,*temp;
    int x;
    clrscr();
    head=(struct node *) malloc (sizeof(struct node));
    temp=head;
    while(temp!=NULL)
    {
        scanf("%d",x);
        temp->data=x;
        if(x==0)
        {temp->next=NULL;}
        else
        {temp->next=(struct node *) malloc (sizeof(struct node));}
        temp=temp->next;
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在编写一个简单的链接列表程序的代码...我可以成功运行该程序但是当我按0时程序没有停止..

c

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

Java 中的泛型方法 &lt;T&gt;

下一个方法是通用的,但我只想知道 ? 的用处是什么<T>?,我的意思是<T>who 位于 static 旁边,位于 void 之前。如果我不在我的方法中编写它会发生什么?

public static <T> void nameMethod(BinaryTreeNode<T> t){
     /*do something
         .
         .
     */
}
Run Code Online (Sandbox Code Playgroud)

谢谢。

java generics

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

编译错误"不兼容的类型"在名为String的Java类中

字符串错误....

我的错误:

C:\Users\Kiran\Desktop\java\bin>javac String.java  
String.java:7: error: incompatible types  
String text = "Hello";  
              ^  
  required: String
  found:    java.lang.String  
String.java:9: error: incompatible types  
String blank = " ";  
               ^
  required: String  
  found:    java.lang.String  
String.java:11: error: incompatible types  
String name = "Kiran";  
              ^  
  required: String  
  found:    java.lang.String    
String.java:13: error: bad operand types for binary operator '+'  
String message = text + blank + name;   
                      ^
  first type:  String  
  second type: String  
4 errors  
Run Code Online (Sandbox Code Playgroud)

我的节目:

public class String {
    public static void main(String args[]) …
Run Code Online (Sandbox Code Playgroud)

java string

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

使用Data.Aeson将JSON转换为Value

如果我事先不知道JSON的结构,如何使用Data.Aeson将JSON转换为Value或Data(Haskell)或者使用任意JSON获取AST?

haskell aeson

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

def方法(参数=无)是什么意思?

class Employee:
    def __init__(self, lastname, firstname = None):
        self.lastname = lastname
        self.firstname = firstname
Run Code Online (Sandbox Code Playgroud)

是什么firstname = None在第二行是什么意思?

python

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

在阻塞中的Haskell缩进

我正在实现Hutton 编写的Haskell编程中的算术表达式树示例,我得到一个语法错误:

解析错误(可能是错误的缩进或括号不匹配)

firstgrm = do t <- secgrm
             ( do { symbol "##";
               o <- firstgrm;
           return (O (t ## o));}
        +++ return t )                         -- parse error here
Run Code Online (Sandbox Code Playgroud)

haskell functional-programming

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

如何在Haskell中的嵌套数据类型中进行更改

我懂了:

type ID = Int

data Bank = Bank [(ID, Account)] deriving Show

data Account = Account
  { balance :: Int
  , owner :: Client
  } deriving Show

data Client = Client
  { name :: String
  , surname :: String
  , address :: String
  } deriving Show
Run Code Online (Sandbox Code Playgroud)

我的任务是,编写一个函数credit :: Int -> ID -> Bank -> Bank ,将指定金额的Money添加到指定金额的帐户.我不知道我怎么能这样做,因为这些是数据类型..

haskell functional-programming

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

如何用erlang创建一个守护程序?

我准备开发一个心跳节目,需要每5秒发送一次udp数据包.

  1. 如何在erlang中睡5s或者是否有睡眠(5)功能?

  2. 如何让它在后台运行?

erlang

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

Java:这段代码有什么问题?

public static void main(String[] args) {
    // TODO code application logic here
    Scanner input = new Scanner(System.in);
    do{
        System.out.print("Enter choice:");
        int choice;
        choice = input.nextInt();
        switch (choice) 
        {
            case 1: 
                FirstProject.areaRectangle();
                break;
            case 2:
                FirstProject.areaTriangle();
                break;
            default:
                System.out.println("lol");
                break;
        }
    }while (input.nextInt()!=0);    
}




public static void areaRectangle() {
    Scanner input = new Scanner(System.in);
    System.out.println("Area of a rectangle.");

    System.out.print("Enter the width: ");
    double width;
    width = input.nextInt();

    System.out.print("Enter the height: ");
    double height;
    height = input.nextInt();

    double areaRectangle = (width * …
Run Code Online (Sandbox Code Playgroud)

java

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

java.lang.ArrayIndexOutOfBoundsException:10

我无法弄清楚问题是有人请帮忙.该程序应该找到数组中重复值的索引并打印出来.输出java.lang.ArrayIndexOutOfBoundsException:10.

private static String s = "";
private static int num = 0;

public static void main(String[] args) {
    int[] array = { 1, 5, 3, 8, 2, 3, 7, 1, 9, 3 };
    for (int i = 1; i <= array.length; ++i) {
        while (num <= array.length - 2 && array[num] == array[i]) {
            s += i + ","; 
            num += 1;
        }
    }
    System.out.println("index 0 are at positions" +s);
    System.out.println();
}
Run Code Online (Sandbox Code Playgroud)

java

-5
推荐指数
1
解决办法
2480
查看次数

Scala - 为什么::不更改List?

我刚刚写了这段代码以获得一些乐趣,我有一个问题,为什么它没有成功?

  val list = List[Int]()

  while (list.length < 20) {  
    Random.nextInt(100) :: list
  }

  println(list)
}
Run Code Online (Sandbox Code Playgroud)

似乎没有任何内容写入列表,但为什么会这样呢?我必须让它变得可变吗?为什么这里的::操作员工作不正常?

scala list immutability

-5
推荐指数
1
解决办法
104
查看次数