473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Example code, String divided.

namespace System
{
public class Text
{
public static System.Char Omin='\t',Next='
',Wciecie='\"',Zamkniecie='\"',Null='\0',Object='˙ ';
public static System.Int32 NextCharacter(System.Int32 i,System.Char[]
litery,System.Char wciecie,System.Char nastepny)
{
for(;i<litery.Length;i++)
{
if(litery[i]==wciecie)
{
return i;
}
if(litery[i]==nastepny)
{
return i;
}
}
return i;
}
public static System.Int32 NextWord(System.Int32 i,System.Char[]
litery,System.Char wciecie,System.Char zamkniecie,System.Char
nastepny,System.Char omin,ref System.String word)
{
for(;i<litery.Length;i++)
{
if(litery[i]==zamkniecie)
{
return i;
}
else if(litery[i]==wciecie)
{
return i;
}
else if(litery[i]==nastepny)
{
return i;
}
else if(litery[i]==omin)
{
return i;
}
else
{
word+=litery[i].ToString();
}
}
return i;
}
public static System.Int32 PoliczWord2(System.String tekst,System.Char
wciecie,System.Char nastepny,System.Char omin)
{
System.Int32 i=0,n=0;
System.Char[] litery=tekst.ToCharArray();
while(i<litery.Length)
{
if(litery[i]==wciecie)
{
i=NextCharacter(i+1,litery,wciecie,Null)+1;
n++;
}
else if(litery[i]==nastepny)
{
i++;
}
else if(litery[i]==omin)
{
i++;
}
else
{
i=NextCharacter(i,litery,wciecie,nastepny);
n++;
}
}
if(i==0)
{
return 0;
}
return n;
}
public static System.String[] Word2(System.String tekst,System.Char
wciecie,System.Char nastepny,System.Char omin)
{
System.String[] wordy=new
System.String[PoliczWord2(tekst,wciecie,nastepny,omin)];
System.Int32 i=0,n=0;
System.Char[] litery=tekst.ToCharArray();
while(i<litery.Length)
{
if(litery[i]==wciecie)
{
i=NextWord(i+1,litery,wciecie,wciecie,Null,Null,re f wordy[n])+1;
n++;
}
else if(litery[i]==nastepny)
{
i++;
}
else if(litery[i]==omin)
{
i++;
}
else
{
i=NextWord(i,litery,wciecie,wciecie,nastepny,omin, ref wordy[n]);
n++;
}
}
return wordy;
}
public static int PoliczWord(System.String tekst)
{
return PoliczWord2(tekst,Wciecie,Next,Omin);
}
public static System.String[] WordFrom(System.String tekst)
{
return Word2(tekst,Wciecie,Next,Omin);
}
public static System.String Word(System.String tekst,System.Int32 numer)
{
System.String word="";
System.Int32 i=0,n=0;
System.Char[] litery=tekst.ToCharArray();
System.Char wciecie=Wciecie,nastepny=Next,omin=Omin;
while(i<litery.Length)
{
if(litery[i]==wciecie)
{
i=NextWord(i+1,litery,wciecie,wciecie,Null,Null,re f word)+1;
if(n==numer)
{
return word;
}
else
{
word="";
}
n++;
}
else if(litery[i]==nastepny)
{
i++;
}
else if(litery[i]==omin)
{
i++;
}
else
{
i=NextWord(i,litery,wciecie,wciecie,nastepny,omin, ref word);
if(n==numer)
{
return word;
}
else
{
word="";
}
n++;
}
}
return word;
}
}
}
pi*********@hotmail.com
Feb 6 '06 #1
2 1618
???

"PioM" <pi**@192.168.2.118> wrote in message
news:ds**********@atlantis.news.tpi.pl...
namespace System
{
public class Text
{
public static System.Char Omin='\t',Next='
',Wciecie='\"',Zamkniecie='\"',Null='\0',Object='˙ ';
public static System.Int32 NextCharacter(System.Int32 i,System.Char[]
litery,System.Char wciecie,System.Char nastepny)
{
for(;i<litery.Length;i++)
{
if(litery[i]==wciecie)
{
return i;
}
if(litery[i]==nastepny)
{
return i;
}
}
return i;
}
public static System.Int32 NextWord(System.Int32 i,System.Char[]
litery,System.Char wciecie,System.Char zamkniecie,System.Char
nastepny,System.Char omin,ref System.String word)
{
for(;i<litery.Length;i++)
{
if(litery[i]==zamkniecie)
{
return i;
}
else if(litery[i]==wciecie)
{
return i;
}
else if(litery[i]==nastepny)
{
return i;
}
else if(litery[i]==omin)
{
return i;
}
else
{
word+=litery[i].ToString();
}
}
return i;
}
public static System.Int32 PoliczWord2(System.String tekst,System.Char
wciecie,System.Char nastepny,System.Char omin)
{
System.Int32 i=0,n=0;
System.Char[] litery=tekst.ToCharArray();
while(i<litery.Length)
{
if(litery[i]==wciecie)
{
i=NextCharacter(i+1,litery,wciecie,Null)+1;
n++;
}
else if(litery[i]==nastepny)
{
i++;
}
else if(litery[i]==omin)
{
i++;
}
else
{
i=NextCharacter(i,litery,wciecie,nastepny);
n++;
}
}
if(i==0)
{
return 0;
}
return n;
}
public static System.String[] Word2(System.String tekst,System.Char
wciecie,System.Char nastepny,System.Char omin)
{
System.String[] wordy=new
System.String[PoliczWord2(tekst,wciecie,nastepny,omin)];
System.Int32 i=0,n=0;
System.Char[] litery=tekst.ToCharArray();
while(i<litery.Length)
{
if(litery[i]==wciecie)
{
i=NextWord(i+1,litery,wciecie,wciecie,Null,Null,re f wordy[n])+1;
n++;
}
else if(litery[i]==nastepny)
{
i++;
}
else if(litery[i]==omin)
{
i++;
}
else
{
i=NextWord(i,litery,wciecie,wciecie,nastepny,omin, ref wordy[n]);
n++;
}
}
return wordy;
}
public static int PoliczWord(System.String tekst)
{
return PoliczWord2(tekst,Wciecie,Next,Omin);
}
public static System.String[] WordFrom(System.String tekst)
{
return Word2(tekst,Wciecie,Next,Omin);
}
public static System.String Word(System.String tekst,System.Int32 numer)
{
System.String word="";
System.Int32 i=0,n=0;
System.Char[] litery=tekst.ToCharArray();
System.Char wciecie=Wciecie,nastepny=Next,omin=Omin;
while(i<litery.Length)
{
if(litery[i]==wciecie)
{
i=NextWord(i+1,litery,wciecie,wciecie,Null,Null,re f word)+1;
if(n==numer)
{
return word;
}
else
{
word="";
}
n++;
}
else if(litery[i]==nastepny)
{
i++;
}
else if(litery[i]==omin)
{
i++;
}
else
{
i=NextWord(i,litery,wciecie,wciecie,nastepny,omin, ref word);
if(n==numer)
{
return word;
}
else
{
word="";
}
n++;
}
}
return word;
}
}
}
pi*********@hotmail.com

Feb 6 '06 #2
PioM <pi**@192.168.2.118> wrote:
namespace System
{
public class Text


Aside from anything else (like the reason for the post) it's a bad idea
to start populating the System namespace yourself, and a *really* bad
idea to create a type called System.Text when there's already a
namespace with that name.

Now, did you have a question?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: sachin bond | last post by:
The following code(in c++) is supposed to divide a file into 'n' different files. suppose i'm having a file called "input.zip". The execution of the following code should divide "input.zip"...
16
by: Jason | last post by:
Hi, I need a way to use random numbers in c++. In my c++ project, when using the mingw compiler I used a mersenne twister that is publicly available and this did its job well. Now I have...
11
by: Lues | last post by:
Hi, I'm trying to protect some data in tables with encription (you know why, don't you ;)) I must confess that I'm not very expirienced in writing code, especially encription code. Can any...
11
by: sethukr | last post by:
hi everybody, char str="string"; str^=str; can anybody plz tell me the use of ^operator in string??? -Sethu
3
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
In my project I want to search thru a text in a text box or RichTextBox. When I search I want to list all lines that contain the string I am searching for. e.g. one plus four two plus four...
3
by: WP | last post by:
Hello! I need some help with my program...it's supposed to read infix expressions line by line from stdin and each expression should be divided into operands and operators and added to a vector of...
31
by: somenath | last post by:
Hi All, I was going through one of the exercise of one C tutorial . In that they have given one small code and asked about the output. #include <stdio.h> int main(void) { int x =...
4
by: Semajthewise | last post by:
Hi All For those of you that helped me with the questions on this... Thank you! I believe I have solved all the bugs in the code and wanted to post the final product. This is a set of code to solve...
1
by: Semajthewise | last post by:
Here it is cleaned up a little more. Here's what this code does. It will take 2 fractions and add, subtract, multiply, or divide them. The user enters the fractions to be calculated into two...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.