This action might not be possible to undo. Are you sure you want to continue?

BooksAudiobooksComicsSheet Music### Categories

### Categories

### Categories

### Publishers

Scribd Selects Books

Hand-picked favorites from

our editors

our editors

Scribd Selects Audiobooks

Hand-picked favorites from

our editors

our editors

Scribd Selects Comics

Hand-picked favorites from

our editors

our editors

Scribd Selects Sheet Music

Hand-picked favorites from

our editors

our editors

Top Books

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Audiobooks

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Comics

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Sheet Music

What's trending, bestsellers,

award-winners & more

award-winners & more

P. 1

Logic Dev Elopement|Views: 93|Likes: 0

Published by Dil Prasad Kunwar

Logic Development for java

Logic Development for java

See more

See less

https://www.scribd.com/doc/52765790/Logic-Dev-Elopement

04/11/2011

text

original

An integer number can be enclosed as an array as follows. Each digit n of the number is represented by n zeros followed by a 1. So the digit 5 is represented by 0,0,0,0,1. The encodings of each digit of a number are combined to form the encoding of the number . so the number 1234 is encoded as the array {0, 1 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1}. The first 0, 1 is contributed by the digit 1, the next 0, 0, 1 is contributed by the digit 2, and so on. There is one other encoding rule: if the number is negative, the first element of the encoded array must be -1, so -201 is encoded as {-1, 0, 0, 1, 1, 0, 1}. Note that the 0 digit is represented by no zeros, i.e. there are two consecutive ones! Write a method named encodeArray that takes an integer as an argument and returns the encoded array. Java Code: import java.util.*; class EncodeArray { public static void main (String[] args) { Scanner in=new Scanner(System.in); int a[] = new int[50]; int i=0,c=0; System.out.println("Enter the number"); int n =in.nextInt(); System.out.printf("The encoded array is:"); System.out.printf("{"); if(n<0) { System.out.printf("-1"+","+" "); n=-n; } while(n!=0) { a[c]=n%10; n=n/10; c++; } for(i=c-1;i>=0;i--) { n=a[i]; if(n==0) { System.out.printf("1"); } else { while(n>0) { n--; System.out.printf("0"+","+" "); if(n==0) {

System.out.printf("1"); } } } if(i>0) { System.out.printf(","+" "); } } System.out.printf("}"); } }

2

2. A positive non-zero number n is a factorial prime if it is equal to factorial(n) + 1 for some n andit is prime. Recall that factorial(n) is equal to 1*2*…*n-1*n. if you understand recursion, the recursive definition is Factorial(1) = n*factorial(n-1). For example, factorial(5) = 1*2*3*4*5 = 120. Recall that a prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. Write a method named isFactorialPrime which returns 1 if its argument is a factorial prime number, otherwise it returns(). Java code: import java.util.*; class IsFactorialPrime { public static void main (String[] args) { System.out.println("Enter the number"); Scanner in=new Scanner(System.in); int a=in.nextInt(); int j=1; for(int i=0;i<j;i++) { j++; if((fact(i)+1)==a) { System.out.printf("1"); j=i-1; } else if((fact(i)+1)>a) { System.out.printf("0"); //break; j=i-1; } } } static long fact(long a) { if(a==0) return 1; else return a*fact(a-1); } }

3

3. An array is called systematically increasing if it consists of increasing sequence of the numbers from 1 to n. The first six (there are over 65,000 of them) systematically increasing arrays are: {1} {1, 1, 2} {1, 1, 2, 1, 2, 3} {1, 1, 2, 1, 2, 3, , 1, 2, 3, 4 } Write a function named isSystematicallyIncreasing which returns 1 if its array argument is systematically increasing. Otherwise it returns(). Java Code: import java.util.*; class IsSystematicallyIncreasing { public static void main (String[] args) { int a[] = new int[50]; System.out.println("Enter the size of array"); Scanner in=new Scanner(System.in); int n=in.nextInt(); System.out.println("Enter the element of array"); int j=0,c=1,t=0,i,p=1,g=1,q=7; for(i=0;i<n;i++) { a[i]=in.nextInt(); } for(i=0;i<n;i++) { for(j=1;j<=c;j++) { if(a[i]==p) { t++; } i++; p++; } i--; p=1; c++; } for(i=0;i<q;i++) { System.out.printf("*"); if(i==6&&g==1) { System.out.printf(" "+"value return"+" "); q=q+7; g++; }

4

} System.out.printf("\n"); if(t==n) { System.out.printf("1"); } else System.out.printf("0"); }

}

5

Transposition Cipher

ASP

Vernam Cipher

Transposition Cipher

SHA-1

Rail – Fence Cipher

Playfair Cipher

Hill Cipher

HASH_CODE

Des Implementation

Caesar Cipher

Pattern Recognition Using Neural Network (Project Proposal for Image Processing)

AI_Lab-3

AI_Lab-1

AI_Lab_2

third semester syllabus

sixth semester syllabus

seventh semester syllabus

Second Semester Syllabus

FIRST SEMESTER SYLLABUS

fifth semster

eighth semester syllabus

fire text

windows folder creation surprise

- Read and print without ads
- Download to keep your version
- Edit, email or read offline

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

CANCEL

OK

You've been reading!

NO, THANKS

OK

scribd

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->