loops

How to Flip the triangle?

一个人想着一个人 提交于 2020-12-15 05:37:03
问题 How to flip this triangle? So i was making aritmethic sequance triangle. It was upside down. How do I turn it 180 degree? for example: 1=1 1+2=3 1+2+3=6 etc... my code: package javaapplication4; public class NewClass5 { public static void main(String[] args) { int i=5,a; for(int j=i; j>=1; j--) { for(a=1; a<=i; a++) System.out.print(a +" + "); int n = 0; for(a = 1; a<=i; a++) { n = n + a; } System.out.print(" = "+ n); System.out.println(); i--; } } } 回答1: You can do it for any n, by getting

Ansible readfile and concatenate a variable to each line

别来无恙 提交于 2020-12-15 05:29:58
问题 Hi I have a file with list of filenames .I want to read each line and add a variable {{version}} to the end and pass it to another task which will download the artifact . MY_File cat file/branches.txt mhr- mtr- tsr I want to get each line add {{version}} to it mhr-1.1-SNAPSHOT mtr-1.1-SNAPSHOT tsr-1.1-SNAPSHOT I couldn't get the file names and append them. below is a failed attempt by me . --- - name: get file names shell: echo {{item}}{{version}} register: result with_lines: cat files

Error displaying Edge labels from pandas dataframe networkx/ error with pos values. dont know which is it

南笙酒味 提交于 2020-12-15 05:16:50
问题 My dataframe has 3 columns, source , target and value. it looks like this source target value BOBA FETT C-3PO 4 BOBA FETT CHEWBACCA 3 BOBA FETT DARTH VADER 8 BOBA FETT HAN 7 G = nx.from_pandas_edgelist(links,source='source',target='target', edge_attr='value') I use this to add my edgelist nx.draw_networkx_edge_labels(G,pos=nx.Graph(G),edge_labels={(u,v):w for u,v,w in G.edges(data='value')}) I tried this to show edge labels. I want the 'value' to be dispplayed as my edge label it gives this

Error displaying Edge labels from pandas dataframe networkx/ error with pos values. dont know which is it

╄→尐↘猪︶ㄣ 提交于 2020-12-15 05:15:39
问题 My dataframe has 3 columns, source , target and value. it looks like this source target value BOBA FETT C-3PO 4 BOBA FETT CHEWBACCA 3 BOBA FETT DARTH VADER 8 BOBA FETT HAN 7 G = nx.from_pandas_edgelist(links,source='source',target='target', edge_attr='value') I use this to add my edgelist nx.draw_networkx_edge_labels(G,pos=nx.Graph(G),edge_labels={(u,v):w for u,v,w in G.edges(data='value')}) I tried this to show edge labels. I want the 'value' to be dispplayed as my edge label it gives this

How to calculate the sum for all files in a directory when to iterate them?

限于喜欢 提交于 2020-12-15 03:44:59
问题 All files in directory survey contain same structure. Data in x1.xls : Data in x2.xls : I want to get sum of b column and c column for both x1.xls and x2.xsl . Result for x1.xls . Same sum for x2.xls . I can do with following steps: 1.Open vb editor in x1.xls 2.Edit the below sub and bind ctrl+z with the sub sum . Sub Sum() Dim BottomOfTable As Long BottomOfTable = Cells(Rows.Count, "A").End(xlUp).Row Cells(BottomOfTable + 1, "A").Value = "score" Range("B" & BottomOfTable + 1).Select

How to calculate the sum for all files in a directory when to iterate them?

无人久伴 提交于 2020-12-15 03:44:16
问题 All files in directory survey contain same structure. Data in x1.xls : Data in x2.xls : I want to get sum of b column and c column for both x1.xls and x2.xsl . Result for x1.xls . Same sum for x2.xls . I can do with following steps: 1.Open vb editor in x1.xls 2.Edit the below sub and bind ctrl+z with the sub sum . Sub Sum() Dim BottomOfTable As Long BottomOfTable = Cells(Rows.Count, "A").End(xlUp).Row Cells(BottomOfTable + 1, "A").Value = "score" Range("B" & BottomOfTable + 1).Select

I want to make Java count from one input integer to another, printing weekdays

本小妞迷上赌 提交于 2020-12-15 03:33:56
问题 So first off, I'm completely brand new to Java and I know this is probably really easy for most of you. But right now I'm stuck with an exercise. I have googled almost frantically, but I can't find any helpful tips to this particular problem. That or I don't really know what to search for. I have a piece of code that looks like this: import java.util.Scanner; public class Week { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Type a number:

R: how to repeatedly “loop” the results from a function?

青春壹個敷衍的年華 提交于 2020-12-14 12:13:49
问题 I have written some code in R. This code takes some data and splits it into a training set and a test set. Then, I fit a "survival random forest" model on the training set. After, I use the model to predict observations within the test set. Due to the type of problem I am dealing with ("survival analysis"), a confusion matrix has to be made for each "unique time" (inside the file "unique.death.time"). For each confusion matrix made for each unique time, I am interested in the corresponding

How to Create a loop (when levels do not overlap the reference)

|▌冷眼眸甩不掉的悲伤 提交于 2020-12-14 12:11:19
问题 I have written some code in R. This code takes some data and splits it into a training set and a test set. Then, I fit a "survival random forest" model on the training set. After, I use the model to predict observations within the test set. Due to the type of problem I am dealing with ("survival analysis"), a confusion matrix has to be made for each "unique time" (inside the file "unique.death.time"). For each confusion matrix made for each unique time, I am interested in the corresponding

R: how to repeatedly “loop” the results from a function?

别来无恙 提交于 2020-12-14 12:10:34
问题 I have written some code in R. This code takes some data and splits it into a training set and a test set. Then, I fit a "survival random forest" model on the training set. After, I use the model to predict observations within the test set. Due to the type of problem I am dealing with ("survival analysis"), a confusion matrix has to be made for each "unique time" (inside the file "unique.death.time"). For each confusion matrix made for each unique time, I am interested in the corresponding