answersLogoWhite

0

In Java

// the string we want to process

final String str = "Mumbai";

// convenience conversion to characters

final char[] str_chars = str.toCharArray();

// letters used to keep track of which characters we've counted

final Set letters = new HashSet();

// iterate through each character in str

for (int i = 0; i < str_chars.length; ++i) {

// store lower case version of ch so we only need to convert once

final char ch_l = Character.toLowerCase(str_chars[i]);

// only process this letter if we haven't done so yet

if (!letters.contains(ch_l)) {

// store letter

letters.add(ch_l);

// count number of times this letter is in str

int count = 1;

for (int j = i + 1; j < str_chars.length; ++j) {

if (ch_l == Character.toLowerCase(str_chars[j])) {

++count;

}

}

// output

System.out.format("%c%d", str_chars[i], count);

}

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

Does the computer programm spark have semantics?

All programming languages have semantics. The semantics of a language are the rules of a language; it defines the meaning of symbols and tokens in the language, and how they interact with each other. Spark is certainly no exception to the rule.


Banking operations in c programm?

here is c code for banking system.... #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;conio.h&gt; #include &lt;dos.h&gt; #include&lt;string.h&gt; #include &lt;graphics.h&gt; #define LEN 100 /*====================================================================*/


Explain the differences between C Language and C plus plus Language?

i want a c programme....if i have a collection of alphabhate appox 2000 or more...alphabates r repeted... i want to write a prograam such that first 7 terms r wrriten in first line then next 7 alphabets r writen in next line.. not fully clear ?? i would give u an example: TTCATCATTCCTAATATTTTTCTTGTAGTTGTTTTAAAAAAGGAATTAAC ATCCAATATTCTGTATTACATACTGTACACCAGATTTTGATTTCAGAAAA CAATATTTGATGTATAACTTCCACTTAATTTAAATTTAATAAACTTTTAT TTCAGAGATATTTGATTAGTTTACAATCTAAGAGTTATTCTTAAGAGTTT CAGTGGAATTTTCTTAATTTTTCTAAAGATATTCCTACTCTCTTGATCAT ATTCTAAGTACATATGAGTACATGTACATTCTTATACAATGTCTAAATGG GTTAGAAAATTATTATACCTATAGAAGCGAAACTTGGAAATTAATAGAAT CACTTAAACCAAAATCTTTATAAGACACAATTCTATTGATTTTAAAGCTT CTGCTTTCCAGGCTCTGTTTTCCAGAGTTTATAATTACGTAGTTTTTAGT AGATGAAAATAATGGATTCTTGTACCTAACATTTTATCCTCTTAGATCTA AGAGCCGAAGCTATAGAACTTTGTTAGACTATTTGGCAAGCAAAATATAT GACAGTAAATATCAGAATTTTATGGTTTGACCAGCGCTTATCACATTCCC AATTCAGTGAGAAAAATTCATCTGGGACACAACAGGGTACTCTTCTCTGT TTGCCCAGAATCAGCTCTGGATTTTAAGCCCAGACTTCAGTGGACCCAGA TAGAAAATATAAAGTCTCTGATCTATAGGCCACATCAGGATGTTATTTTA TGAAGAGTTCTAGAGCAAGGTTGCGGAAATCGGGGTGGAGATGGGGAGCA GTGACTCCTCCAAATATTCATTGCTAACAGGCCATTCTATGCAGTTTGTT TTAACAAATCCTGGGTTAAACTGAGGCCACAGGACATGATGGGCTGTTCT ATAAAGCATTCTAAGTGGAGAGGAGACGATAGGGCATATGAAATTCACTA AACTCTCTGGAAAAAAAATATGTATATATTAAAAACCAAGACTGGAATCA GTGCAACAGTGGGAACTACCTTTTACAAGTATCCATTGCTTCATAAACTC CATTTGTTTGGACCAATCCCTTAAACAAAAGCAAGGCAAATTTTACATGG ATTTAGAGCCTAGGTCAGGTTATTAGGATTATAAATTTTCCACTGGTATG TCATTGTGATTATCTTTGTTTTTGTCTTTCTGAAAGATTGGATTTTCTAT AACACCTTGTGTAAGAAAATAAAAAACTTGATCTAACTGAA suppose this is a sequence... i want to write first 7 alphabets in first line...(1st to seventh) TTCATCA next 7 in next line...(2nd to ...8th) TCATCAT next 7(3rd to 9th)....and so on.... can u help me to write this programm.... if u write this programm u get a treat from me....


What is stray pointer?

stray pointer is a that pointer which pin points nothing or anywhere but we dont know... for example: int *ptr; ptr=new int[10]; //this memory is on heap. and at the end of the programm if we dont delete this memory mean to say if we dont deallocate this memory then this type of pointer is pointing towards nothing or anywhere because when we work on heap deletion of pointer is must if we dont delete pointers than they pin point stray or anywhere so that sort of pointer is stray pointer. i think you understand...


Write a programm for addition of two numbers in C plus plus language?

Addition is an intrinsic operator that applies to all primitive data types, both signed and unsigned. There is no need to program it. The operands can be literal, constant or variable, hard-wired or generated from user-input, it makes no difference whatsoever. #include&lt;iostream&gt; int main() { std::cout&lt;&lt;"The sum of 1 and 2 is "&lt;&lt;(1+2)&lt;&lt;std::endl; std::cout&lt;&lt;"The sum of 1.5 and 2.3 is "&lt;&lt;(1.5, 2.3)&lt;&lt;std::endl; return(0); }