我刚开始学习使用HashMap并阅读java教程,但我遇到了麻烦.
我正在尝试更新HashMap中的List,但是我想获取该密钥的列表,是否有办法更新密钥的特定列表而不必制作... 5个不同的列表并更新它们?
HashMap<String, ArrayList<String>> mMap = new HashMap<String, ArrayList<String>>();
ArrayList<String> list = new ArrayList<String>();
mMap.put("A", list);
mMap.put("B", list);
mMap.put("C", list);
mMap.put("D", list);
Iterator iter = mMap.entrySet().iterator();
if (mMap.containsKey("A"))
{
Map.Entry mEntry = (Map.Entry) iter.next();
list.add("test");
mMap.put("A",list);
System.out.println(mEntry.getKey() + " : " + mEntry.getValue());
}
else if (mMap.containsKey("B"))
{
Map.Entry mEntry = (Map.Entry) iter.next();
list.add("entry");
mMap.put("B",list);
System.out.println(mEntry.getKey() + " : " + mEntry.getValue());
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试扫描单行输入并将其存储在结构中.我不确定我是否存储错误或者我打错了.我不知道如何使用scanf与for循环,因为我以前从来没有做到提ç喜欢的东西覆盖.所以我不确定如何处理这个问题.
这是我放在一起的东西,但是当我打印时,我得到了垃圾数字.我本打算使用指针,但我的教授不会让我们使用它.这就是我遇到麻烦的原因.
EDITED
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 3
#define MAXTRIP 6
struct stop
{
float cost;
float time;
};
struct trip
{
char Dest_letter;
int stop_num;
struct stop leg[MAX];
};
int main(void)
{
int trip_num, index, i;
struct trip travel[MAXTRIP];
printf("Enter number of trips: ");
scanf("%d", &trip_num);
printf("Please enter destination letter/number of stops and cost/length of each stop:\n");
for (index = 0; index < trip_num; index++)
{
scanf("%c %d", &travel[index].Dest_letter, &travel[index].stop_num);
for …Run Code Online (Sandbox Code Playgroud) char copy, array[20]
printf("enter ..."):
scanf("%s", array);
if (strlen(array) > 20 )
{
strcpy(copy, array....);
Run Code Online (Sandbox Code Playgroud)
如果输入超过20个字符,我需要做什么才能使它只抓取前20个字符
我正在制作一个主控制页面,在图像上有不同的链接,现在唯一的问题是我希望图像适合整个页面并重新调整大小(窗口),如果它们缩小(在某种程度上)并放大它.
<img src ="image/main.jpg" style="width:100%;height:100%; min-width:600px; min-height:400px;" alt="Main" usemap="#MainMap">
<map name="MainMap">
<area id="login" class="login" shape="circle" coords="91,677,92">
<area id="money_management" class="money" shape="circle" coords="598,680,92">
<area id="withdraw_history" shape="circle" coords="596,304,67">
<area id="transaction_history" shape="circle" coords="784,624,67" href="History.html">
<area id="cart" shape="circle" coords="396,698,67,92">
<area id="buy" shape="circle" coords="898,352,92">
<area id="sell" shape="circle" coords="718,438,92">
<area id="new" shape="circle" coords="570,132,92" href="New.html">
</map>
Run Code Online (Sandbox Code Playgroud)
我之前有这个,当我使图像静态并让它在其他东西上工作时,我希望在重新调整窗口大小后更新坐标我知道如何在jquery中检测重新调整大小我找不到任何语法更新坐标的示例.
我正在尝试将变量从一个函数传递到另一个函数.
例如:
FuncA:从用户接收3个输入,我想在FuncB中使用这3个输入.
我该怎么办?我只是从FuncA返回3个值并将其作为Func B的参数传递给我吗?
我会这样做吗?**不使用指针.
int FuncA(void);
int FuncB(int A, int B, int C, int D, int E);
int main(void)
{
FuncA(void);
FuncB(A,B,C);
}
int FuncA(void)
{
printf("Enter 3 number:");
scanf("%d %d %d" &A, &B, &C);
return A, B, C;
}
int FuncB(int A, int B, int C)
{
.............
}
Run Code Online (Sandbox Code Playgroud) 是否有一种正确的方法可以在某个点之后复制字符串的一部分.
Party City 1422 Evergreen Street
Run Code Online (Sandbox Code Playgroud)
我使用strpbrk()来复制名称,我总是可以通过空格来标记它,但是有一个字符串过程或技术,我可以复制出一个字符串的特定部分,从一开始就像复制只是[1422 Evergreen Street ]或删除字符串的第一部分?
我不确定这是否可行.
有没有办法在图像上的特定坐标上放置超链接?
防爆
_____________________________________
| |
| xxx |
| xxx |
| |
| |
| |
| zzz |
| zzz |
| |
|___________________________________|
Run Code Online (Sandbox Code Playgroud)
有没有办法在xxx位置设置超链接,并在图像的zzz位置设置单独的超链接.我该如何开始呢?
DIR * d;
int dsize=0;
struct dirent * de;
char *dir[1024];
d=opendir(".");
while ((de = readdir(d)))
{
if((de->d_type) & DT_DIR)
{
dir[dsize]= de->d_name;
dsize++;
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试将文件名的地址存储到char指针数组中.
指针有点生疏我回去看了一些指针评论的页面,但我不确定我做错了什么..继续告诉我"警告:赋值从指针生成整数而没有强制转换".我的语法是否因为结构而关闭?
/*
Program to calculate trip and plan flights
*/
#define TRIP 6
#define DEST 1
#define NUMLEG 10
#include <stdio.h>
int error_leg(int leg_num);
char error_leg_type(char leg_type);
int main(void)
{
int i, trip_num, row, col, leg_num, checkE, z, layer,
travel_leg[TRIP][NUMLEG];
char leg_type, travel_leg_type[TRIP][NUMLEG][DEST], checkF;
printf("Please enter the number of trips:");
scanf("%d", &trip_num);
while (trip_num > TRIP)
{
printf("Invalid number of trip. (Min of 3 trips and Max 6 trips).\n"); /*input number of trips*/
printf("Please enter the number of trips:");
scanf("%d", &trip_num); …Run Code Online (Sandbox Code Playgroud) if ( (code == S || M || L || N || P || K ||R || C || U || W || O) )
{
return T;
}
Run Code Online (Sandbox Code Playgroud)
我正确使用或运营商吗?我打算成为其中一个角色,但我不确定我是否正确使用了算子