Jump to content

Syntro126

Members
  • Posts

    2
  • Joined

  • Last visited

About Syntro126

  • Birthday 08/09/1995

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Syntro126's Achievements

Newbie

Newbie (1/14)

10

Reputation

  1. Mersi pentru sfaturi, am rezolvat. Am scos n si m[] si am schimbat if- ul ala si mi-a iesit
  2. Salut, m-am apucat de cateva zile de java si incerc sa fac un program sa-mi transforme text in binar dar nu prea imi iese. Cand introduc textul imi apare cate un 0 pentru fiecare litera. Metoda binary am verificat-o separat si merge. package bench; import java.util.Scanner; public class Function { public static void main(String args[]){ Scanner input = new Scanner(System.in); String text = input.nextLine(); int n = text.length(); int m[] = new int[n]; String x[] ={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}; for(int i = 0; i < text.length(); i++){ for(int j = 0; j < x.length ; j++){ if(text.substring(i,i+1) == x[j]) m = 97 + j; } } for(int j1 = 0 ; j1 < m.length ; j1++){ binary(m[j1]); } } public static void binary(int c){ int d = 1 , e = 0 ; while(c >=1 ){ if(c % 2 == 0) d = d*10; else d = d*10 + 1; c = c / 2; } while(d > 1){ e = e*10 + d % 10; d = d/10; } System.out.print(e + " "); } }
×
×
  • Create New...