int

Adding two variables - php

橙三吉。 提交于 2019-12-25 14:05:41
问题 I am in the process of designing a php validated form for a restaurant website which directs the user to a thank you page, displaying their reservation details, once they have pressed submit. Currently I have 2 variables, one named 'party', the other named 'vip'. These variables both display a string value when echoed. However, I wish to assign them an int value and then add them together to display a total price to the user. Currently I have this code which does not seem to function: <b

Dynamicaly set byte[] array from a String of Ints

南楼画角 提交于 2019-12-25 13:15:36
问题 i usualy set my byte[] arrays like this: byte[] byteArr = { 123, 234, 123, 234, 123, 123, 234 }; now, my problem, i am getting the datas that have to be stored into the array as a string. example: string datas = "123, 234, 123, 234, 123, 123, 234"; i would like to do something like: byte[] byteArr = { datas }; with no luck... I tried exploding the string to array of strings, then convert each value to Int before storing into each array field. with no luck: for (var i = O; i<datasArray.length;

Is there an algorithm to find all the common sub-sequences of items in 2 List<List<int>>, PRESERVING THE ORDER?

浪子不回头ぞ 提交于 2019-12-25 10:49:12
问题 There are 2 Lists. I have to find all the sub-sequences of integers contained in BOTH the List>, where the ORDER IS PRESERVED. List<List<int>> listOfLists1 = new List<List<int>>(); List<int> list1 = new List<int>() { 1, 2, 3, 4, 5, 6 }; List<int> list2 = new List<int>() { 5, 7, 8 }; listOfLists1.Add(list1); listOfLists1.Add(list2); List<List<int>> listOfLists2 = new List<List<int>>(); List<int> list3 = new List<int>() { 5, 1, 2, 5 }; List<int> list4 = new List<int>() { 3, 4, 5, 7, 8 }; List

In C, can you have a 128-bit bitfield [duplicate]

牧云@^-^@ 提交于 2019-12-25 09:18:05
问题 This question already has answers here : Maximum size of a bit field in C or C++? [duplicate] (2 answers) struct bitfield max size (C99, C++) (4 answers) Closed 3 years ago . Is the following code legal? struct BigInt { uint64_t a : 128; }; 回答1: A bitfield must fit within a single int , so you're out of luck unless int is 128 bits on your platform. (You were also missing a ; at the end of the struct prior to the edit.) 回答2: Not legal in standard C11 (on most platforms; in principle, an int

prefix notation string to int conversion

孤人 提交于 2019-12-25 08:24:07
问题 I've been trying to think of a way to convert a string to an integer, I know the old atoi() in C and as well as the sstream function to convert a string type to a integer. I am trying to a write a program that that takes in a prefix notation and produces a result recursively. The program works, when I use char instead of string, but I am not really sure how I am suppose to use strings to solve this problem. I have to have it so that the user enter + 3 3 and result is 6. #include <iostream>

Error by reading binary file with c++

别等时光非礼了梦想. 提交于 2019-12-25 07:18:16
问题 I try to read in a binary file containing char and int & double after a header: // open file int pos = 0,n; char str1,str2; //string str; ifstream fid(pfad.c_str(),std::ios::binary); if (fid.good() != 1) { printf(" ++ Error: The elegant bunch file %s doesn't exist.\n",pfad.c_str()); return 1; } // cut the header while (pos<5) { if (fid.eof()) { printf(" ++ Error: elegant bunch file is strange\n"); return 1; } fid >> str1; switch (pos) { case 0: str2 = '&'; break; case 1: str2 = 'd'; break;

How can I pad nullable ints with zeros?

流过昼夜 提交于 2019-12-25 06:56:04
问题 Is there any way to pad nullable int with zeros the way you can with normal int? the myInt.ToString("D3") doesn't seem to work on nullale ints but for my current project I feel like I need to use nullable int in order to get the null value in my array instead of 0 as the default. 回答1: That is because int? is actually Nullable<T> where T is int here. Calling ToString will call that on the Nullable struct, not the int . Nullable<T> has no knowledge of the overloads of ToString which int has.

PHP String to Int Conversion Losing Value (using simple_html_dom)

本小妞迷上赌 提交于 2019-12-25 06:45:26
问题 so I'm using simple_html_dom to parse a page for elements with a particular class. I successfully retrieve those elements but cannot seem to get them converted into usable variables (ie an integer so I can do an 'if' statement). It seems they are an object of some kind, and I've searched everywhere for hours, but no luck. There doesn't seem to be much support for simple_html_dom. Here's my code: /////////////// $html = new simple_html_dom(); // Load a file $html->load_file($getURL); $getName

Type mismatch exception

折月煮酒 提交于 2019-12-25 06:37:17
问题 I am developing game, Initially I was using boolean while decalring arrays, latter it revealed that instead of using boolean I should use int in order to store state of game, When I replaced boolean with int my if statement shows type mismatch exception and The operator && is undefined for the argument type(s) boolean, int . Here is my if statement code. int [][] dots protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawPaint(pBack); for (int y = 0; y < numRows; y++) {

How to make such construction return values form 0 to 1?

房东的猫 提交于 2019-12-25 06:26:38
问题 It give me only 1s int maxVal; int minVal; int wh = w*h; int values[1000]; for(x=0;x<w;x++){ for(y=0;y<h;y++){ double RealColor = cvGetReal2D(source, y, x); values[x*y + y] = RealColor; } } minVal = *min_element(values,(values+wh)); maxVal = *max_element(values,(values+wh)); float dif = maxVal - minVal; float fminVal; fminVal = minVal; for(x=0;x<w;x++){ for(y=0;y<h;y++){ float rc = cvGetReal2D(source, y, x); float normRealColor =(rc - fminVal + 1) / dif; file << normRealColor << " "; } file <