You are on page 1of 4

 

import java.io.*; 
class Problem1 { 
  public static void main(String[] args)throws IOException 
  { 
  int i,n; 
  BufferedReader x=new BufferedReader (new InputStreamReader(System.in)); 
  System.out.print(" Tamaño vectores : ");n=Integer.parseInt(x.readLine()); 
   int [] v1=new int [n]; 
  int [] v2=new int [n]; 
  int [] v3=new int [n]; 
  for(i=0;i<n;i++){ 
    v1[i]=1+(int)(Math.random()*10); 
    v2[i]=1+(int)(Math.random()*10); 
  } 
  for (i=0;i<n;i++) 
  v3[i]=v1[i]+v2[i]; 
  System.out.print("vector (A): "); 
  for(i=0;i<n;i++) 
  System.out.print(v1[i]+"\t"); 
  System.out.println(""); 
  System.out.print("vector (B): "); 
  for(i=0;i<n;i++) 
  System.out.print(v2[i]+"\t"); 
  System.out.println(""); 
  System.out.print("Suma (A+B): "); 
  for(i=0;i<n;i++) 
  System.out.print(v3[i]+"\t"); 
  } 

 
 
import java.io.*; 
class Problem2 { 
  public static void main(String[] args)throws IOException 
  { 
  int i,n; 
  BufferedReader x=new BufferedReader (new InputStreamReader(System.in)); 
  System.out.print(" Tamaño vectores : ");n=Integer.parseInt(x.readLine()); 
   int [] v1=new int [n]; 
  int [] v2=new int [n]; 
  for(i=0;i<n;i++){ 
    v1[i]=1+(int)(Math.random()*10); 
    v2[i]=1+(int)(Math.random()*10); 
  } 
  System.out.print("vector (A): "); 
  for(i=0;i<n;i++) 
  System.out.print(v1[i]+"\t"); 
  System.out.println(""); 
  System.out.print("vector (B): "); 
  for(i=0;i<n;i++) 
  System.out.print(v2[i]+"\t"); 
  System.out.println(""); 
  System.out.print("Interseccion (AB): "); 
  for(i=0;i<n;i++) 
  if (v1[i]==v2[i]) 
  System.out.print(v1[i]+"\t"); 
  } 

 
import java.io.*; 
import java.util.regex.Matcher; 
import java.util.regex.Pattern; 
class Problem3 { 
  public static void main(String[] args)throws IOException{ 
  String Email,Name; 
  Pattern Plantilla=null; 
  Matcher Resultado=null; 
  BufferedReader x=new BufferedReader (new InputStreamReader(System.in)); 
  Plantilla=Pattern.compile("^([0‐9a‐zA‐Z]([_.w]*[0‐9a‐zA‐Z])*@([0‐9a‐zA‐Z][‐w]*[0‐9a‐zA‐Z].)+([a‐zA‐
Z]{2,9}.)+[com]{2,3})$"); 
  System.out.print(" Ingrese su nombre: ");Name=x.readLine(); 
  do{ 
  System.out.print(" Ingrese su correo: ");Email=x.readLine(); 
  Resultado=Plantilla.matcher(Email); 
  }while(Resultado.find()==false); 
  int pos=Email.indexOf("@"); 
  String newEmail=Email.substring(0,pos); 
  System.out.print("Su correo es: "+newEmail+" cuenta perteneciente a: "+Name); 
  } 

 
import java.io.*; 
class Problem4 { 
  public static void main(String[] args)throws IOException{ 
  String Email; 
  int i; 
  BufferedReader x=new BufferedReader (new InputStreamReader(System.in)); 
  System.out.print("ingrese texto: ");Email=x.readLine(); 
  System.out.print("\n"); 
  System.out.println("Ingresado: "+Email); 
  for(i=0;i<=100;i++){ 
  Email=Email.replaceAll("(.)\\1", "$1"); 
  } 
  System.out.println("Transform: "+Email.toUpperCase()); 
  } 

 
import java.io.*; 
public class Problem5{ 
    public static void main(String[] args) throws IOException{ 
      BufferedReader w=new BufferedReader(new InputStreamReader(System.in)); 
    int [][]mat=new int[20][20]; 
    int N; 
    String Unidad[]={"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"}; 
      String Decena[]={"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}; 
      System.out.print("Ingrese tamaño de la matriz: ");N = Integer.parseInt(w.readLine()); 
      int paso=1,cont=1; 
       for(int i=0;i<N;i++) 
     { 
        if(paso==1) 
    { 
        for(int j=0;j<N;j++) 
    { 
           if (mat[i][j]==0) 
         mat[i][j]=cont++; 
       } 
        } 
    paso++; 
        if(paso==2){ 
      for (int j=0;j<N;j++){ 
            if (mat[j][N‐(i+1)]==0) 
        mat[j][N‐(i+1)]=cont++;} 
        }paso++; 
        if(paso==3){for (int j=N‐1;j>=0;j‐‐){ 
            if (mat[N‐(i+1)][j]==0)mat[N‐(i+1)][j]=cont++;} 
        }paso++; 
        if(paso==4){for (int j=N‐1;j>=0;j‐‐){ 
            if (mat[j][i]==0)mat[j][i]=cont++;} 
        }paso=1; 
        } 
    for (int f=0;f<N;f++){ 
        for (int c=0;c<N;c++){ 
       int u=mat[f][c]%10; 
       int d=(mat[f][c]/10)%10; 
          if(mat[f][c]>=10){ 
              System.out.print(Decena[d]+Unidad[u]+"      ");         
          }else{ 
              if(mat[f][c]<10) 
              System.out.print(Unidad[u]+"      ");           
          }    
    } 
       System.out.println(); 
     } 
   } 
 } 
 
import java.util.*; 
import java.io.*; 
public class Problem6{ 
    public static void main(String[] args) throws IOException{ 
      BufferedReader ing=new BufferedReader(new InputStreamReader(System.in)); 
    int [][]mat=new int[20][20]; 
    int i,j,F,C,aux; 
      System.out.print("Numero de filas: ");F = Integer.parseInt(ing.readLine()); 
    System.out.print("Numero de columnas: ");C = Integer.parseInt(ing.readLine()); 
    for(i=1;i<=F;i++){ 
      for(j=1;j<=C;j++){ 
      System.out.print("fila["+i+"]columna["+j+"]");mat[j][i] = Integer.parseInt(ing.readLine()); 
    }System.out.println(); 
    } 
    for(i=1;i<=F;i++){ 
      for(j=1;j<=C;j++){ 
        System.out.print(mat[j][i]+"  "); 
  }System.out.println(); 
  } 
   
  for(int x=1;x<=C;x++){ 
    for(int y=1;y<=C;y++){ 
      for(int z=1;z<=C;z++){ 
        for(int w=1;w<=C;w++){ 
          if (mat[x][y]<mat[z][w]){ 
            aux=mat[x][y]; 
            mat[x][y]=mat[z][w]; 
            mat[z][w]=aux; 
            } 
        } 
      } 
    } 
  } 
  System.out.println(); 
  for(int a=1;a<=F;a++){ 
      for(int b=1;b<=C;b++){ 
        System.out.print(mat[b][a]+"  "); 
  }System.out.println(); 
  } 
  } 

You might also like