java - How do I get the power of each string based on its length? -


मेरे पास 15 की एक स्ट्रिंग है: "10101000000010" । मैं अनन्य या अर्थात् ^ [/ p>

int s = a [3] ^ a [5] ^ ए [7] ^ ए [9] ^ ए [11] ^ ए [13] ^ लेना चाहता हूं। एक [15];

  // here skips 1 सूचकांक सभी तरह से स्ट्रिंग के अंत तक जो 7 है। int t = a [3] ^ a [6] ^ a [ 7] ^ ए [10] ^ ए [11] ^ ए [14] ^ ए [15]; // here ^ skips 2 index and lets 2 go, और इतने पर ...   

मैं यह करने के लिए एक एल्गोरिथ्म कैसे तैयार करूं? मैं बस excluisve या प्रत्येक सूचकांक लेने के बाद int चाहता हूं।

तो सवाल क्या है, मुझे क्या करना है अगर स्ट्रिंग की लंबाई 20 है, तो मैं कैसे

निम्न कोड आपके अनुरोध को पूरा करता है

  सार्वजनिक स्थिर इंट पावर (स्ट्रिंग ए) {int total = 0; के लिए (int i = 3; i & lt; a.length (); i + = 3) {कुल ^ = (int) a.charAt (i); } कुल वापसी; }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -