Hi, So how exactly do we take the length of an int array? Lets say that there is an array called int nums []={2, 1, 2, 3, 4}; Is there a function that can be used to find it?

Member Avatar
Member Avatar
+0 forum 8

I'm working with a LIST that am getting from a soup which after the clean up gives me: lists of variable length ['7.0', '7.5', '6.8', '6.9'] or ['7.0', '7.5'] so my problem is when I try formating the output: code snippet: if grades: print '\r\n["' + str(student[0]), if len(grades) == 1: print print ('%s'*len(grades)) % tuple(grades) the output of this is: >> ["John Doe 7.0 7.5 6.8 6.9 however what I need is: ["John Doe, ["7.0","7.5"],["6.8","6.9"]] or ["John Doe, ["7.0","7.5"]] I've tried with Formatter and Template and seems can't be done with those. thank you

Member Avatar
Member Avatar
+0 forum 5

How would I write this program: Wrte a program that will read a line of text that ends witha period, which serves as a sentinal value. Display all the letters that occur in the text, one per line and in alphabetical order, along with the number of times each letter occurs in the text. Use an array of base type int of length 26, so that the element at index 0 contains the number of a's, the element and index 1 contains the number of b's and so forth. Allow both uppercase and lowercase letters as input, but treat uppercase …

Member Avatar
Member Avatar
+0 forum 7

I am attempting to write a code with several different segment, such as combine two differents strings, compare two strings, find the length of a string. Right now, I am working on the part to get the string length, but when I run the code I have so far on Mars and QTSpim, instead of getting a length of 1, I am getting 0 to the first power displayed as the answer. What have I done wrong? .data S1: .asciiz "I " S2: .asciiz "love " S3: .asciiz "assembly" string: .asciiz "Our three strings are:\n" S4: .asciiz "\nThe three strings …

Member Avatar
Member Avatar
+0 forum 8

Hi. I need help with my size method. I am using a single-linked list. I tested my code and it returns 0 all the time. /** This method returns the size of the current list. <br> * If the current list has no elements,it is empty. <br> * * @return size of the current list*/ public int size() { //A counter to keep track of the elements in the list int listCounter = 0; //initialize the first element as head Node<T> node = head; //if node is null, then the list is empty //and an empty list has 0 elements …

Member Avatar
Member Avatar
+0 forum 7

yesterday I was disucsing with more experienced programmer. He saw that I am using for (var i =0; i< 6; i++) So 6 is the static number. I was iterating throug array. He said to use lengh, just in case array lemngh is not 6. I say - its always 6. Its not planned to be not 6. He says still - who knows maybe code will be changed. Ok, there might be some reason. But then I say - for me it looks more readable. When I see 6 - I know its 6 and nothing else. WHen I …

Member Avatar
Member Avatar
+0 forum 9

Hi all, I'm writing a simple application in C# but I'm having an annoying ArgumentOutOfRangeException thrown by Invoke() saying "Text length must be less than 64 characters long.". Is this usual that strings passed through delegates have to be shorter than 64 characters? What's the usual neat way around it? Do I have to box it in some container class? The code is here: public enum StatusIcons { NoChange, Idle, Download, Fail, Reply, ShuttingDown, Pause } ; public void updateStatus(string description, StatusIcons icon = StatusIcons.NoChange, string tooltip = null) { if (this.InvokeRequired) { System.Diagnostics.Debug.Print("invoke {0},{1}: \r\n{2}\r\n{3}", description.Length, tooltip!= null ? …

Member Avatar
Member Avatar
+0 forum 2

Hi Friends, I have PSKC XML file.. That contains my Salt/Key,IV(Initialization Vector),Encrpted Data,password also. Now, I am trying to Do Password Based Encyption and Decryption Using PBEWITHSHA1AND128BITAES-CBC-BC Algorithm. It works,If i generate salt and IV randomly. But,it fails to work,if i dont generate it randomly... Instead of generating Salt and IV randomly.. i am using my own salt,IV,password and everything.. Here is my code.... import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.SecureRandom; import java.security.Security; import java.security.spec.InvalidKeySpecException; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.SecretKeySpec; import org.bouncycastle.crypto.PBEParametersGenerator; import org.bouncycastle.crypto.digests.SHA256Digest; import org.bouncycastle.crypto.engines.AESEngine; import org.bouncycastle.crypto.generators.PKCS12ParametersGenerator; import org.bouncycastle.crypto.modes.CBCBlockCipher; import org.bouncycastle.crypto.paddings.PKCS7Padding; import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher; …

Member Avatar
Member Avatar
+0 forum 5

So I was asked to write some simple functions that would search through an array of length (s) and tell how many times an (integer, double etc. ) appeared within the array. It's pretty simple because they give you the length of the array. However one of the functions doesn't have a length passed with the other parameters! char arrayX(char a[], char v) Where you are asked to find amount of times value (v) is in the array. What is the simplest way to do this? What would be the most efficient if the array turned out to be VERY …

Member Avatar
Member Avatar
+0 forum 17

Hello everyone happy new year to all. i want get length of only fractional part of number in java script function. example if number is 4.321 then length of fractional part is 3. please help me. thank you

Member Avatar
Member Avatar
+0 forum 3

What would be the best way (or any way) to print out a pattern, that may cut off at any point dependant on the x & y length? for example, if i wanted a pattern 4 up (y = 4) and 14 across (x = 14) I would need it to print: m//m//m//m//m/ m//m//m//m//m/ m//m//m//m//m/ m//m//m//m//m/ I'm thinking a nested for loop so: for(i=1; i<y; i++){ //then another thing inside so that would make 4 lines total, but with the pattern printing along the x axis… but how?? Thanks in advance for any help given. Michael

Member Avatar
Member Avatar
+0 forum 8

The string is about 3k long. It contains a substring several times with the following specification: 1. First part is FIXED number of characters. The same for all the substrings. 2. Second part is the one to be extracted and stored in an array.It is of variable length 3. Third part is FIXED number of characters. Part 1 & 3 contains all types of characters including special characters and regex metacharacters. I am attaching sort of pesudo code just to summarize my problem my @substringArray; my $longString; my $subStart="START"; my $subEnd = "END"; while (How to loop a string ???) …

Member Avatar
Member Avatar
+0 forum 4

I need to do the following: input First and Last name Output initials. Output however many letters Input Middle name Output Full initials. then redo the process. input First and Last name Output initials. Output however many letters Input Middle name. Output Full initials. Example: Enter your first and last name with a space between: Melvin Mathew Your initials are MM. Your name has 12 letters. What's your middle name: TOM Your full Initials are MTM. Enter your first and last name with a space between: Melvin Mathew Your initials are MM. Your name has 12 letters. What's your middle …

Member Avatar
Member Avatar
+0 forum 3

Hello Friends, I want to set the length of the textfield in java... Please check my below code....it works finely if I press the keys one by one slowly... But suppose if I press any key for a longer time the actual length exceeds and so the validation is not done correctly... Can anyone help me to set the length?? public class TextValidation extends KeyAdapter { public void keyReleased(KeyEvent key) { Object txt=key.getSource(); if(txt==txtPatientId) { char ch=key.getKeyChar(); String specialchar="!@#$%^&*()~?>'<:{}|+_/\".,;'][=-` \\"; if (txtPatientId.getText().trim().length() <= 10) { if (specialchar.indexOf(ch)>-1) { JOptionPane.showMessageDialog(null, "SPECIAL CHARACTER IS NOT ALLOWED","Title",JOptionPane.WARNING_MESSAGE); txtPatientId.setText(txtPatientId.getText().substring(0, txtPatientId.getText().length()-1)); } } else { …

Member Avatar
Member Avatar
+0 forum 5

Hi all, I have a PHP script that takes a string and lists all its permutations, but ONLY based on its length. So for instance, let's just say we had the word "racecar". Yes, it would list all permutations of the 7-character word "racecar" such as "acrerac", etc. but NOT words like "race" or "car" that have a smaller length. Here is my code: function check($word) { if (strlen($word) < 2) { return array($word); } $permutations = array(); $tail = substr($word, 1); foreach (check($tail) as $permutation) { $length = strlen($permutation); for ($i = 0; $i <= $length; $i++) { $permutations[] …

Member Avatar
Member Avatar
+0 forum 9

Hi there, I was reading a book on the plane and something interesting came to my mind that needs an answer. The length property of objects is a read/write value. Let's say, you've got an array that has 6 elements in it and you change its length to 10 as shown below. var array = ["hello", "world", "daniweb"]; alert(array.length); // this will give you three array.length = 10; // Here is the line that changes the value of length alert(array.length); // this will give 10 Why would someone change the value of length property? what is the advantage of doing …

Member Avatar
Member Avatar
+0 forum 9

I put together a vb.net program that does some string parsing and creates a fixed-width file at the end. When I run it on each of my 2 machines it creates a properly formatted file. When my client downloads the msi file, installs it, and runs it, he gets several extra spaces on each record of the file, and the number of spaces is inconsistent from record to record. Here is the code, although it runs fine on my side, so I am thinking it must have something to do with the compiler maybe??? The spaces are added to the …

Member Avatar
Member Avatar
+0 forum 5

[ICODE]#include <iostream> using namespace std; void GetRoomTiles(int WidthFeet, int WidthInches, int &TotalWidth, int LengthFeet, int LengthInches, int &TotalLength, int TileSize, int &RoomTiles); void GetTotalTiles(int RoomTiles, int &TotalTiles); void GetNumberOfBoxes(int TotalTiles, int TileBoxes, int &ExtraTiles, int &NumberOfBoxes); int main() { int NumberOfRooms; int TileSize; int WidthFeet, WidthInches, TotalWidth; int LengthFeet, LengthInches, TotalLength; int RoomTiles, TotalTiles; int NumberOfBoxes = 0; int TilesBoxes = 20; int ExtraTiles = 0; ExtraTiles++; cout << "Enter the number of rooms needed for tiles:"; cin >> NumberOfRooms; if (NumberOfRooms <= 0) cout << "Please re-enter a positive value greater than 0." << endl; TileSize = -1; cout …

Member Avatar
Member Avatar
+0 forum 1

My name is Leonard Norwood Jr. If anyone knows a program that will estimate the number of boxes of tile needed for a job. A job is estimated by taking the dimensions of each room in feet and inches and converting these into a multiple of the tile size (rounding up any partial multiple) before multiplying to get the number of tiles for the room. A box should have 20 tiles, so I need to divide the total number needed by 20 and rounded up to get the number of boxes (they are square). Here is what I have so …

Member Avatar
Member Avatar
+0 forum 8

Can i change the array's rows length after i define it as constant or any other way? Can you under my code or explanation? [CODE]#include<stdio.h> #define CLASS_SIZE 20 //First define the array rows's length void main() { double gpa, average, highest, lowest; int student, rows, i, j; char grade[CLASS_SIZE][5]; //Wish to change the CLASS_SIZE printf("Enter the number of student : "); scanf("%d", &CLASS_SIZE); //Can i change the arrays length after declared ? for(j=0;j<CLASS_SIZE;j++) //What should i modify? { printf("\nStudent No.%d :\n", j+1); for(i=0;i<5;i++) { printf("Enter subject %d's grade : ", i+1); fflush(stdin); scanf("%c", &grade[j][i]); } } printf("+===========+=============================+\n"); printf("| | SUBJECT …

Member Avatar
Member Avatar
+0 forum 1

I'm trying to write a program that takes a string and prints one letter per line. I need to use a while loop based on string length. I googled, so sorry for the newbie question. Thanks!

Member Avatar
Member Avatar
+0 forum 4

hello friends, I got a problem with an object array.I'll write a sample code for understand the problem.I declared an array of objects named item. [CODE]item[] itemAr = new item[100];[/CODE] And then I initialized some of them [CODE]itemAr[0]=****; itemAr[1]=****; itemAr[2]=****;[/CODE] I want to know that is there a way to find out how many array elements are initialized like this.(In this case its just 3).I tried with [ICODE]item.length[/ICODE] but it returns 100 which is the size of array. thank you all.

Member Avatar
Member Avatar
+0 forum 8

Hi, I need to find the 'length' of union between 2 vectors. The code I have is[CODE] vector<int> v1,v2; vector<int> unionsetv; vector<int>::iterator it; v1.push_back(1);v1.push_back(2);v1.push_back(3); v2.push_back(3);v2.push_back(2);v2.push_back(4); it = set_union(v1.begin(),v1.end(),v2.begin(),v2.end(),back_inserter(unionsetv)); cout << unionsetv.size()<< " "; cout << int(it - unionsetv.begin())<< " " ; [/CODE] I could not get this to work and I have used the set_union in the same way as given in the cplusplus.com reference. If I remove the iterator 'it' then I get the entire size of the unionsetv vector (here this is 6) but this will have zero values in it (obtained during union). What I need is …

Member Avatar
Member Avatar
+0 forum 7

Hey guys, I need to find the length of a long variable (how many numbers it holds). So if the variable holds: '1234567890' then I want to return an int value of '10'. varName.Length() doesn't work, and I haven't found anything from google or msdn. Thanks for the help, - [B][I]WolfShield[/I][/B]

Member Avatar
Member Avatar
+0 forum 5

The End.