我是一个真正的一级忍者,想要解决我的作业,但我不能这样做:
所以任务是:
说一个介于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) #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时程序没有停止..
下一个方法是通用的,但我只想知道 ? 的用处是什么<T>?,我的意思是<T>who 位于 static 旁边,位于 void 之前。如果我不在我的方法中编写它会发生什么?
public static <T> void nameMethod(BinaryTreeNode<T> t){
/*do something
.
.
*/
}
Run Code Online (Sandbox Code Playgroud)
谢谢。
字符串错误....
我的错误:
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) 如果我事先不知道JSON的结构,如何使用Data.Aeson将JSON转换为Value或Data(Haskell)或者使用任意JSON获取AST?
class Employee:
def __init__(self, lastname, firstname = None):
self.lastname = lastname
self.firstname = firstname
Run Code Online (Sandbox Code Playgroud)
是什么firstname = None在第二行是什么意思?
我正在实现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) 我懂了:
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添加到指定金额的帐户.我不知道我怎么能这样做,因为这些是数据类型..
我准备开发一个心跳节目,需要每5秒发送一次udp数据包.
如何在erlang中睡5s或者是否有睡眠(5)功能?
如何让它在后台运行?
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.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) 我刚刚写了这段代码以获得一些乐趣,我有一个问题,为什么它没有成功?
val list = List[Int]()
while (list.length < 20) {
Random.nextInt(100) :: list
}
println(list)
}
Run Code Online (Sandbox Code Playgroud)
似乎没有任何内容写入列表,但为什么会这样呢?我必须让它变得可变吗?为什么这里的::操作员工作不正常?