[Show all top banners]

The Joker
Replies to this thread:

More by The Joker
What people are reading
Subscribers
:: Subscribe
Back to: Computer/IT Refresh page to view new replies
 Coding Challenge!!! C++
[VIEWED 3117 TIMES]
SAVE! for ease of future access.
Posted on 02-06-15 1:28 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?        
 


coding challenge for all the pros

use a circular array to create a circular representation for the n-bit number. The cyclic shift operations will change where the first bit starts in the number. The cyclic shift left shifts every bit to the left by one position and the leftmost bit moves cyclically to the vacated rightmost position. Similarly, the cyclic shift right shifts every bit to the right by one position and the rightmost bit moves cyclically to the vacated leftmost position.
example: input (1 1 1 1 0 0 0 0)
output (1 1 1 0 0 0 0 1 )
 
Posted on 07-18-15 6:44 PM     [Snapshot: 387]     Reply [Subscribe]
Login in to Rate this Post:     0       ?        
 

Hey there, don't post your assignment here, do it yourself.
 
Posted on 07-19-15 4:37 AM     [Snapshot: 472]     Reply [Subscribe]
Login in to Rate this Post:     0       ?        
 

You would have get better help if you have stated "help" instead of challenge.
 
Posted on 07-19-15 4:48 AM     [Snapshot: 476]     Reply [Subscribe]
Login in to Rate this Post:     0       ?        
 

Try stackoverflow.com
 
Posted on 07-19-15 1:28 PM     [Snapshot: 594]     Reply [Subscribe]
Login in to Rate this Post:     0       ?        
 

here is java version but other way around..
output (1111000) 
next iteration: 0111100
next iteration:0011110 and so on

import java.util.Scanner;

/**
*
* @author wiwi
*/
public class JavaApplication15 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

System.out.println("Please enter your no");
Scanner myScanner = new Scanner(System.in);
int number = myScanner.nextInt();
String numberString = "";
numberString = Integer.toString(number);
int sizeOFstring = numberString.length();
char[] myArray = new char[sizeOFstring];
char[] tempArray = new char[sizeOFstring];
for (int i = 0; i < sizeOFstring; i++) {

myArray[i] = numberString.charAt(i);
tempArray[i] = numberString.charAt(i);
}

String choice = " ";
int n = 0;
while (n == 0) {
//System.out.println("size of array" + myArray);
System.out.println("Please press ('N') or ('n') to start cycle");
System.out.println("Please press any key to quit");
choice = myScanner.next();

if ((choice.equals("N")) || (choice.equals("n"))) {

int j = 0;
myArray[0] = tempArray[sizeOFstring - 1];

for (int i = 1; i < sizeOFstring; i++) {
myArray[i] = tempArray[j];
j++;

}
for (int i = 0; i < sizeOFstring; i++) {
tempArray[i] = myArray[i];
j++;

}

for (int i = 0; i < sizeOFstring; i++) {
System.out.print(tempArray[i]);
}
System.out.println();
} else {
System.out.println("Thank you");
n = 1;
}

}

}
}
Last edited: 19-Jul-15 01:30 PM

 
Posted on 07-19-15 1:41 PM     [Snapshot: 650]     Reply [Subscribe]
Login in to Rate this Post:     0       ?        
 

kasto khatey magney ho yar..help chaiye ta help bhanda k ko laaj...thukka ni...teri soch ra jindagi.
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 30 days
Recommended Popular Threads Controvertial Threads
~चौतारी १९९~
हामीहरुले २० जना केटिहरुसंग सेक्स गर्नै पर्छ रे नी !
TPS to GC (PERM-I140-I485) TimeLine
TPS FEDERAL NOTICE
नफर्किने गरि नेपाल जाने सोच
TPS to change of status denied ..Need help
थुक्क प्रियंका कार्कीजी …
US upcoming recession --- is it good time to buy house when rates are low or is it good time to wait recession?
अमेरिकामा एक नेपाली युवक आफ्नै ओछ्यानमा मृत भेटिए
TPS EAD rejected: Help
Salary offer aako cha
लामिछानेको येस्पलीको दसैँ मामाघरमा
Mnang, Mustang Treking and Our Engagement
♪♪♪ हामी सबै क्लबमा ♪♪♪
Thing to do for Parents after coming to USA.
Is QA/BA worth considering a career ??
Invest between 20-30lakhs
Greencard ko bare
चीन र जापानमा भन्दा पहिले नेपालमा बिजुली बलेकाे थियो | 2nd hydropower project of Asia
"Itiahariko" copied Itahariko username!!!!
~चौतारी १९९~
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters