I can't understand why does vector empty after it's filling.
The code is:
bool fillArray (vector<int> &array)
{
string temp;
getline(cin, temp);
if (temp == "-1")
return false
else
return true;
int res = atoi(temp.c_str());
array.push_back(res);
}
void showArray(const vector<int> array)
{
for (int i = 0; i < array.size(); i ++)
cout << array[i] << " ";
}
int main(int argc, char** argv)
{
vector<int> array;
while (fullArray (array))
{}
showArray(array);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
When I input -1 the …
我有一个dockpanel,我使用ItemsControl动态填充以填充面板.dockpanel需要来自itemscontrol列表的最后一个子节点来填充面板的其余部分,但是如果我以这种方式填充它似乎不会发生...我该怎么做才能让最后一个项目扩展?
我如何设置它的片段:(注意我将dockpanel背景设置为蓝色,以便我可以区分填充的用户控件和面板的背景)
<DockPanel Background="Blue" LastChildFill="True" Margin="0">
<ItemsControl ItemsSource="{Binding Requirements}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<local:TMGrid2View Baseline="{Binding}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DockPanel>
Run Code Online (Sandbox Code Playgroud)
我目前关于发生了什么的假设是将子填充应用于itemscontrol而不是itemscontrol中填充的子代.我过去曾经使用过setter来指定孩子应该停靠在面板的一侧......例如,似乎没有一个子设置器选项来让它扩展...
我有这个代码来绘制三角形画布.但是,除了黑色,我无法获得填充颜色.它声称可以使用ctx.fillStyle,但它没有.我必须在代码中遗漏一些东西你们可以看看吗?
function drawShape(){
// get the canvas element using the DOM
var canvas = document.getElementById('balkboven');
// Make sure we don't execute when canvas isn't supported
if (canvas.getContext){
// use getContext to use the canvas for drawing
var ctx = canvas.getContext('2d');
var ctxwidth = window.innerWidth;
// Filled triangle
ctx.canvas.width = window.innerWidth;
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(ctxwidth,0);
ctx.lineTo(0,105);
ctx.fill();
ctx.fillStyle="red"
}
}
Run Code Online (Sandbox Code Playgroud) 我很惊讶我没有在任何地方找到答案.我想用1..100填充100的int数组.填充是一种很好的方法,但它不会在每个回合中增加值.它显然是如何用循环做的,但我想避免这种情况,因为我的最大值非常高.有没有api方法可以为我做这个?
我试图用'-1'填充2D数组作为所有值.我正在使用的代码是:
int c [] []=new int[4][4];
Arrays.fill(c,-1)
Run Code Online (Sandbox Code Playgroud)
这会引发以下错误:
Exception in thread "main" java.lang.ArrayStoreException: java.lang.Integer
Run Code Online (Sandbox Code Playgroud)
谁能告诉我代码中有什么问题?
我正在尝试创建类似程序的绘画,我正在实现一个桶填充工具.我正在存储已绘制的所有点并使用Graphics2D drawLine
绘制实际线,因此我不想存储桶填充的所有点(因此我不想进行填充).
对于桶填充,到目前为止,我已经使用a BufferedImage
来填充不在我的列表中但仍在绘制的点.
我想做的一件事就是只存储最外面的点,而不是fillPolygon
使用这些点来使用Graphics2D .唯一的问题是我不确定如何找到这些点.
我被困在这里,所以有人有任何想法吗?
如何在excel中填充一定数量的行?
让我们说5,它用数字填充5行,比如1 2 3 4 5
(每个单元格向下1个数字).如果我将其更改为12,则应该导致1 2 3 4 5 6 7 8 9 10 11 12
.
我可以通过拖动公式=A1+1
来做到这一点,但后来我必须手动调整最后一个数字(它将从~50到~900之间变化)
[解决了]
我想创建包含 40 个元素的数组(10x 值“c”,10x 值“d”,10x 值“h”,10x 值“s”)。我尝试创建数组:
$znaczki = array_fill(0, $iloscZnaczkow, 'c');
$znaczki = array_fill($iloscZnaczkow, $iloscZnaczkow, 'd');
$znaczki = array_fill((2 * $iloscZnaczkow), $iloscZnaczkow, 'h');
$znaczki = array_fill((3 * $iloscZnaczkow), $iloscZnaczkow, 's');
Run Code Online (Sandbox Code Playgroud)
Var $IloscZnaczkow 包含数字 - 10。不幸的是,稍后我将使用 $znaczki 和脚本
$i = 0;
foreach ($serializ as $key => $value) {
echo '<img src="images/' . $value . $znaczki[$i] . '.gif" />';
$i++;
}
Run Code Online (Sandbox Code Playgroud)
抛出图像 src="images/11.gif" (它没有 $znaczki[$i] 无处不在 :()
I am trying to make a heatmap in R, that along with the fill should also show the values and along with filling, should also include a row and column without applying fill on them.
My data looks like this
Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Sum
1999 116 127 202 229 253 271 271 245 212 174 133 115 2348
2000 114 154 193 214 263 271 254 248 210 167 120 …
Run Code Online (Sandbox Code Playgroud) 我有一个 data.table 这样的:
missings_table = data.table( name = c("Jim","Paul",NA,"Sam"),
midterm = c(0,15,13,12),
final = c(0,NA,16,13));missings_table
Run Code Online (Sandbox Code Playgroud)
我想做的是类似于
nafill(missings_table$final,type = "const", fill = 0)
Run Code Online (Sandbox Code Playgroud)
但如果我尝试
nafill(missings_table$name,type = "const", fill = "name")
Run Code Online (Sandbox Code Playgroud)
我得到
'x' argument must be numeric type, or list/data.table of numeric types
Run Code Online (Sandbox Code Playgroud)
谢谢 :)
我想用光谱颜色填充曲线下的区域,得到这样的图。
这就是我尝试过的
ggplot(bq, aes(x=w.length, y=s.e.irrad)) +
geom_segment(aes(xend=w.length, yend=0, colour=abs(w.length)^0.7*sign(w.length))) +
geom_line() +
scale_colour_gradient2(low=scales::muted("blue"),
mid=scales::muted("green"),
high=scales::muted("red"))
Run Code Online (Sandbox Code Playgroud)
得到这个
还尝试使用 geom_area
ggplot(bq, aes(x = w.length, y = s.e.irrad))+
geom_area(fill = "steelblue") #steelblue is for example
Run Code Online (Sandbox Code Playgroud)
但无法填充渐变
我的数据框的 x 为波长,y 为辐照度
const size_t bytes
我有一个流,我需要多次用文本 ( )填充精确大小( const char * filler = "Something"
) ,直到达到字节大小。
像这样:SomethingSomethingSomething或SomethingSome,如果没有更多可用字节,则可以将其截断,但它始终必须是精确的大小。例如字节为 30
const size_t bytes = 30;
const char * text = "Something";
int x = bytes / strlen(text);
for (int j = 0; j < x; j++)
{
for (int i = 0; i < strlen(text); i++)
{
stream << text[i];
}
}
Run Code Online (Sandbox Code Playgroud)
像上面这样,我只能用未截断的单词填充流,而不是:SomethingSomethingSomethingSom(这正好是 30)
我该如何修改这段代码?谢谢你!
我有这个ggplot2
脚本:
require(reshape2)
library(ggplot2)
library(RColorBrewer)
library(extrafont)
font_import(pattern = 'Arch')
font_import(pattern = 'Akk')
fileName = paste("/ex_spectra.csv", sep = "") # data: https://www.dropbox.com/s/gs1hwv3xjnlhb7z/ex_spectra.csv?dl=0
mydata = read.csv(fileName,sep=",", header=TRUE, check.names=FALSE)
dataM = melt(mydata,c("x"))
my_palette = c(brewer.pal(5, "Set1")[c(1,2,3,4,5)])
ggplot(data=dataM, aes(x= x, y=value, colour=variable, fill = variable, size = variable)) +
geom_line(alpha = .75) +
scale_colour_manual(breaks=c("A", "B", "C", "D", "E"), values=my_palette) +
scale_size_manual(breaks=c("A", "B", "C", "D", "E"), values=c(0.7,0.7,0.7,0.7,0.7)) +
theme(plot.background = element_blank(), panel.grid.minor = element_blank(), #panel.grid.major = element_blank(),
axis.line = element_blank(),
legend.key = element_blank(), legend.title …
Run Code Online (Sandbox Code Playgroud)