loops

Copying and pasting loop in VBA Excel for multiple outputs

一个人想着一个人 提交于 2020-07-09 07:13:12
问题 So I have the following excel tabs: Code 1, Code 2, Code 3, LI, 2015, 2016, 2017, 2018, 2019, output for 2015 etc. For 2015, I have a table in '2015' tab with 10 rows a list of 3 code and their respective % values. e.g. ref name yr code 1 % code 2 % code 3 % 12345 NAME 2015 AB 50% CD 37% EF 13% 78901 NAME 2015 AX 54% OD 30% NG 6% 26572 NAME 2015 AE 60% CD 27% PF 13% I need the code 1 'AB' and % '50%' to be put into cells B5 and B6 in the tab Code 1. Same for codes 2 and 3 'CS' and '37%' in B5

Copying and pasting loop in VBA Excel for multiple outputs

雨燕双飞 提交于 2020-07-09 07:12:19
问题 So I have the following excel tabs: Code 1, Code 2, Code 3, LI, 2015, 2016, 2017, 2018, 2019, output for 2015 etc. For 2015, I have a table in '2015' tab with 10 rows a list of 3 code and their respective % values. e.g. ref name yr code 1 % code 2 % code 3 % 12345 NAME 2015 AB 50% CD 37% EF 13% 78901 NAME 2015 AX 54% OD 30% NG 6% 26572 NAME 2015 AE 60% CD 27% PF 13% I need the code 1 'AB' and % '50%' to be put into cells B5 and B6 in the tab Code 1. Same for codes 2 and 3 'CS' and '37%' in B5

Program to check any number exist in 2D array

こ雲淡風輕ζ 提交于 2020-07-09 05:47:12
问题 I know how to check if number exist in the array, but not in a 2D array . Please help me in 2D. #include<iostream> using namespace std; int main() { int a[3] = { 4,5,6 }; int b, c; int x = 1, fact = 1; cout << "enter no "; cin >> b; for (int i = 0; i < 3; i++) { if (b == a[i]) { c = a[i]; break; } } cout << "no entered is present" << endl; } 回答1: I know how to check if number exist in the array, but not in 2D array! It is like you did for the one-dimensional array, instead of one, you need to

Ansible: iterate over a list of dictionaries - loop vs. with_items

我与影子孤独终老i 提交于 2020-07-09 05:13:42
问题 I'm getting different results when using loop vs with_items when trying to iterate over a list of dictionaries. I've tried using loop|dict2items (the structure isn't a dictionary, & it tells me as much. heh) and loop with the flatten filter. Here is the list of dictionaries: "msg": [ { "id": "id1", "ip": "ip1", "name": "name1" }, { "id": "id2", "ip": "ip2", "name": "name2" }, { "id": "id3", "ip": "ip3", "name": "name3" }, { "id": "id4", "ip": "ip4", "name": "name4" } ] } Here is the task in

Ansible: iterate over a list of dictionaries - loop vs. with_items

南楼画角 提交于 2020-07-09 05:13:01
问题 I'm getting different results when using loop vs with_items when trying to iterate over a list of dictionaries. I've tried using loop|dict2items (the structure isn't a dictionary, & it tells me as much. heh) and loop with the flatten filter. Here is the list of dictionaries: "msg": [ { "id": "id1", "ip": "ip1", "name": "name1" }, { "id": "id2", "ip": "ip2", "name": "name2" }, { "id": "id3", "ip": "ip3", "name": "name3" }, { "id": "id4", "ip": "ip4", "name": "name4" } ] } Here is the task in

Ansible: iterate over a list of dictionaries - loop vs. with_items

删除回忆录丶 提交于 2020-07-09 05:12:16
问题 I'm getting different results when using loop vs with_items when trying to iterate over a list of dictionaries. I've tried using loop|dict2items (the structure isn't a dictionary, & it tells me as much. heh) and loop with the flatten filter. Here is the list of dictionaries: "msg": [ { "id": "id1", "ip": "ip1", "name": "name1" }, { "id": "id2", "ip": "ip2", "name": "name2" }, { "id": "id3", "ip": "ip3", "name": "name3" }, { "id": "id4", "ip": "ip4", "name": "name4" } ] } Here is the task in

Python - Determine Tic-Tac-Toe Winner

我的未来我决定 提交于 2020-07-06 20:42:37
问题 I am trying to write a code that determines the winner of a tic-tac-toe game. (This is for a college assignment) I have written the following function to do so: This code only checks for horizontal lines, I haven't added the rest. I feel that this is something that needs a bit of hardcoding. def iswinner(board, decorator): win = True for row in range(len(board)): for col in range(len(board)): if board[row][col] == decorator: win = True else: win = False break Where "board" is a 2D array of

Javascript variable declaration within loop

蹲街弑〆低调 提交于 2020-07-06 11:12:29
问题 I have a habit that I am borderline compulsive about, but I think may be completely unnecessary. With code like: function abc(){ var a,b; for(var i=0;i<10;i++){ a=document.getElementsByTagName('LI').item(i).width; b=document.getElementsByTagName('DIV').item(i).width; // now do something with a and b } return; } I am compulsive about declaring the variable before the loop as opposed to: function abc(){ for(var i=0;i<10;i++){ var a=document.getElementsByTagName('LI').item(i).width; var b

how to change single char in string array?

走远了吗. 提交于 2020-07-03 11:56:43
问题 Having this: #include <stdio.h> #include <stdlib.h> #include <ctype.h> char *up(char *); int main() { char initstr[20]; printf("enter string\n"); fgets(initstr, 20, stdin); char *str = up(initstr); printf("%s\n", str); } char *up(char *in) { char *ret; for (ret = in; *in != '\n'; *(ret++) = toupper(*(in++)) ); return ret; } Run it as: $./a.out enter string abc #only new line from `printf("%s\n",str);` From debugger Hardware watchpoint 3: in Old value = 0x7fffffffdc20 "abc\n" New value =

how to change single char in string array?

狂风中的少年 提交于 2020-07-03 11:56:11
问题 Having this: #include <stdio.h> #include <stdlib.h> #include <ctype.h> char *up(char *); int main() { char initstr[20]; printf("enter string\n"); fgets(initstr, 20, stdin); char *str = up(initstr); printf("%s\n", str); } char *up(char *in) { char *ret; for (ret = in; *in != '\n'; *(ret++) = toupper(*(in++)) ); return ret; } Run it as: $./a.out enter string abc #only new line from `printf("%s\n",str);` From debugger Hardware watchpoint 3: in Old value = 0x7fffffffdc20 "abc\n" New value =