Quick Search


Tibetan singing bowl music,sound healing, remove negative energy.

528hz solfreggio music -  Attract Wealth and Abundance, Manifest Money and Increase Luck



 
Your forum announcement here!

  Free Advertising Forums | Free Advertising Board | Post Free Ads Forum | Free Advertising Forums Directory | Best Free Advertising Methods | Advertising Forums > Post Your Free Ads Here in English for Advertising .Adult and gambling websites NOT accepted. > Other

Other Post anything that does not fit in the above categories here.

Reply
 
Thread Tools Display Modes
Old 06-19-2011, 07:22 PM   #1
thanks0152
 
Posts: n/a
Default language agnostic - Adjacent number algorithm grou

By which I imply this:

Given the input set of numbers:

1,two,three,four,5 becomes "1-5".

1,Windows 7 Starter Product Key,2,Windows 7 Home Basic,three,microsoft office 2007 sale,5,7,Office 2007 Professional Product Key,9,10,eleven,twelve,14 turns into "1-3, 5,Learning causes structural changes in affected neurons.html, 7, 9-12, 14"

This may be the best I managed to come up with: [C#]

Which feels a bit sloppy to me, so the concern is, is there in some way a lot more readable and/or stylish resolution to this?

public static string[] FormatInts(int[] ints)
{ if (ints == null) throw new ArgumentNullException("ints"); // hey what are you doing? if (ints.Length == 0) return new string[] ""; // practically nothing to process if (ints.Duration == one) return new string[] ints[0].ToString(); // nothing at all to procedure Array.Sort(ints); // need to sort these lil' babies List values = new List(); int lastNumber = ints[0]; // start with the first number int firstNumber = ints[0]; // same as above for (int i = one; i < ints.Length; i++) { int current = ints[i]; int difference = (lastNumber - current ); // compute difference between last number and current number if (difference == -1) // the numbers are adjacent { if (firstNumber == 0) // this is the first of the adjacent numbers firstNumber = lastNumber; else // we're somehow in the middle or at the end of the adjacent number set lastNumber = current; continue; } else { if (firstNumber > 0 && firstNumber != lastNumber) // get ready to print a set of numbers { values.Add(string.Format("0-1", firstNumber, lastNumber)); firstNumber = 0; // reset } else // print a single value { values.Add(string.Format("0",Office Standard 2007 Product Key, lastNumber)); } } lastNumber = current; } if (firstNumber > 0) // if theres anything left, print it out { values.Add(string.Format("0-1", firstNumber, lastNumber)); } return values.ToArray();
}
  Reply With Quote
Old 06-19-2011, 07:28 PM   #2
SvetaCyple
 
Posts: n/a
Default Просто Светлана

Quote:
Штатный оптимист МИДа, заместитель министра Дани Аялон, заявил, что речь Барака Обамы носит позитивный для Израиля оттенок. ..."В речи Обамы, действительно, говорилось о создании палестинского ...
Интерестно... Вот что вы об этом думаете?
Mожет обсудим одит интерестный , я думаю момент. Точнее небольшую цитату из новостей. Да кстате. Нашла очень даже не плохой видеоонлаин. Главное полезного много и без рекламы!!! Извените, отвлекаюсь, собственно говоря перейдем к самой выдетжке.
  Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On


All times are GMT. The time now is 10:04 AM.

 

Powered by vBulletin Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Free Advertising Forums | Free Advertising Message Boards | Post Free Ads Forum