14 December 2012

GTA SA PERSIDENT ESCORT MOD FOR CLEO3 CLEO4

GTA San Andreas Protection Mode 
FOR 
CLEO3 & CLEO 4

STEP 1: Before Using This MOD Please Install CLEO Library.
STEP 2: Download escort.cs File and ADD it to CLEO Folder Of your GTA San Andreas GAME.
STEP 3: Just Press 9 to start President convoy Protection Mod When you are in CAR/Bike.
STEP 4: After Completion of your work just again Press 9 and the Protection will be Turned off.

(FOR SECURITY PROTOCOL PRESIDENT(YOU) THE TRAFFIC WILL BE DISABLE TILL YOU ARE IN ESCORT VEHICLE PROTECTION. )

10 December 2012

GTU CORE JAVA file handling programs


Simple Program to print text to a file

 //print text to a file  
 import java.io.*;  
 import static java.lang.System.out;  
 class file1  
 {  
 public static void main(String args[])  
 {  
 FileOutputStream o;  
 PrintStream p;  
 try  
 {  
 o=new FileOutputStream("file1.txt");  
 p=new PrintStream(o);  
 p.println("hello world..!");  
 p.println("From Niraj Chauhan");  
 p.close();  
 }  
 catch(Exception e)  
 {  
 out.print("error Writing a file to Hdisk");  
 }  
 }  
 }  
Print Data variables to a file
 //print data to a file  
 import java.io.*;  
 import static java.lang.System.out;  
 class file2  
 {  
 public static void main(String args[])  
 {  
 FileOutputStream o;  
 PrintStream p;  
 try  
 {  
 o=new FileOutputStream("file2.txt");  
 p=new PrintStream(o);  
 int a=10;  
 float b=123.23F;  
 p.println("a="+a+"\nb="+b);  
 p.close();  
 }  
 catch(Exception e)  
 {  
 out.print("error Writing a file to Hdisk");  
 }  
 }  
 }  
/copy one file to another file ( PLEASE PASS FILE NAME AS ARGUMENTS)
 //copy one file to another file  
 import java.io.*;  
 class file4  
 {  
 public static void main(String args[])throws Exception  
 {  
 int n=args.length;  
 if(n==0)  
 System.out.print("PLEASE ADD CMD LINE ARGUMENT AS FILE NAME");  
 else  
 {  
 FileOutputStream out=new FileOutputStream("filecopy.txt");  
 for(int i=0;i<n;i++)  
 {  
 try  
 {  
 InputStream in = new FileInputStream(args[i]);  
 byte buf[]=new byte[1024];  
 int len;  
 while ((len = in.read(buf)) > 0)  
 {  
  out.write(buf, 0, len);  
 }  
 in.close();  
 }  
 catch(Exception e)  
 {  
 }  
 }  
 }  
 }  
 }  
Create a Directory from core java program
 //create a directory  
 import java.io.*;  
 class file6  
 {  
 public static void main(String args[])throws Exception  
 {  
 int n=args.length;  
 if(n==0)  
 System.out.print("PLEASE ADD CMD LINE ARGUMENT AS DIR NAME");  
 else  
 {  
 for(int i=0;i<n;i++)  
 {  
 try  
 {  
 boolean success = (new File(args[i])).mkdir();  
 if(success)  
 System.out.println("Dir "+args[i]+" Successfully Created..!");  
 else  
 System.out.println("Dir "+args[i]+" NOT Successfully Created..!");  
 }  
 catch(Exception e)  
 {  
 }  
 }  
 }  
 }  
 }  
Make a file name data.txt and save following data
0001Niraj Chauhan 010020030
0002Pratik G patel 010020030
0003Ankur Shah 010020030
0004Amit Parekh 010020030
0005Chetan Chawda 010020030

 //Read file & print after Calculations  
 import java.io.*;  
 import static java.lang.System.out;  
 class student  
 {  
 int rollno,sub1,sub2,sub3,total;  
 String name;  
 float per;  
 student()  
 {  
 System.out.print("ih");  
 }  
 student(int rollno,String name,int sub1,int sub2,int sub3)  
 {  
 this.rollno=rollno;  
 this.sub1=sub1;  
 this.name=name;  
 this.sub2=sub2;  
 this.sub3=sub3;  
 }  
 public void showdata()  
 {  
 out.println("\n\n==================================");  
 System.out.println("No:"+rollno+"\tname:"+name);  
 out.println("==================================");  
 System.out.println("Sub1:"+sub1);  
 System.out.println("Sub1:"+sub2);  
 System.out.println("Sub1:"+sub3);  
 out.println("==================================");  
 out.println("Total:"+(sub1+sub2+sub3));  
 out.println("per:"+((sub1+sub2+sub3)/3)+"%");  
 }  
 }  
 class file8  
 {  
 public static void main(String args[])throws Exception  
 {  
 int count=0;  
 try  
 {  
 FileReader fr=new FileReader("data.txt");  
 BufferedReader br=new BufferedReader(fr);  
 String n1;  
 count=0;int i=0;  
 count=line("data.txt");  
 student s[]=new student[count];  
 while((n1=br.readLine())!=null)  
 {  
 int no=Integer.parseInt(n1.substring(0,4));  
 String name=n1.substring(4,26);  
 int no1=Integer.parseInt(n1.substring(26,29));  
 int no2=Integer.parseInt(n1.substring(29,32));  
 int no3=Integer.parseInt(n1.substring(32,35));       
 s[i]=new student(no,name,no1,no2,no3);  
 s[i].showdata();  
 i++;  
 }  
 System.out.println("\nTotal No Of Records Inserted:"+count);  
 }  
 catch(Exception e)  
 {  
 out.println("\nInput File Damaged..of total line "+count);  
 }  
 }  
 static int line(String fn)throws Exception  
 {  
 FileReader fr=new FileReader("data.txt");  
 BufferedReader br=new BufferedReader(fr);  
 String n1;int x=0;  
 while((n1=br.readLine())!=null)  
 {  
 x++;  
 }  
 return x;  
 }  
 }  
Read a file Line By line
 //Read file line by line  
 import java.io.*;  
 class file5  
 {  
 public static void main(String args[])throws Exception  
 {  
 int n=args.length;  
 if(n==0)  
 System.out.print("PLEASE ADD CMD LINE ARGUMENT AS FILE NAME");  
 else  
 {  
 for(int i=0;i<n;i++)  
 {  
 try  
 {  
 boolean success = (new File(args[i])).mkdir();  
 FileReader fr=new FileReader(args[i]);  
 BufferedReader br=new BufferedReader(fr);  
 String n1;  
 while((n1=br.readLine())!=null)  
 {  
 System.out.println(n1);  
 }  
 }  
 catch(Exception e)  
 {  
 }  
 }  
 }  
 }  
 }  


print content of a file by passing file name arguments
 //print content of a file by passing file name arguments  
 import java.io.*;  
 import static java.lang.System.out;  
 class file3  
 {  
 public static void main(String args[])throws Exception  
 {  
 int n=args.length;  
 if(n==0)  
 out.print("PLEASE ADD CMD LINE ARGUMENT AS FILE NAME");  
 else  
 {  
 for(int i=0;i<n;i++)  
 {  
 try  
 {  
 out.println("\n\nthe contents of "+args[i]+" is :\n\n");  
 InputStream in = new FileInputStream(args[i]);  
 byte buf[]=new byte[1024];  
 int len;  
 while ((len = in.read(buf)) > 0)  
 {  
  out.write(buf, 0, len);  
 }  
 in.close();  
 }  
 catch(Exception e)  
 {  
 }  
 }  
 }  
 }  
 }  

29 August 2012

Data Structure Programs

0) Program of singly linked list
1) Program on Linked list, New node insert at begining position.
2)Program on Linked list, New node insert at begining position.
3)Program on Linked list, New node insert so that information field and store in ascending order.
4)Program: To delete a node whose value is given by x from singly Linked list.
 #include<iostream.h>  
 #include<conio.h>  
 #include<stdlib.h>  
 struct list  
 {  
 int info;  
 struct list *link;  
 }*node1,*temp,*first;  
 int ch,x;  
 void menu()  
 {  
 cout<<endl<<"singly linked list";  
 cout<<endl<<"=======================";  
 cout<<endl<<"1.insert a nod";  
 cout<<endl<<"2.display a nod";  
 cout<<endl<<"3.display in reverse";  
 cout<<endl<<"0.Exit";  
 cout<<endl<<"=======================";  
 cout<<endl<<"enter your choice:";  
 cin>>ch;  
 }  
 void insert()  
 {  
 cout<<"Enter x:";  
 cin>>x;  
 node1=(struct list *)malloc(10);  
 node1->info=x;  
 node1->link=NULL;  
 if(first==NULL)  
 first=node1;  
 else  
 {  
 node1->link=first;  
 first=node1;  
 }  
 }  
 void rev()  
 {  
 temp=first;  
 int i=0;  
 while(temp!=NULL)  
 {  
 i++;  
 temp=temp->link;  
 }  
      for(;i>0;i--)  
      {  
           temp=first;  
           for(int j=1;j<i;j++)  
           temp=temp->link;  
           cout<<temp->info<<" ";  
      }  
 }  
 void display()  
 {  
 temp=first;  
 while(temp!=NULL)  
 {  
 cout<<temp->info<<" ";  
 temp=temp->link;  
 }  
 }  
 void del()  
  {  
   int x;  
     if (first==NULL)  
       cout<<endl<<"Underflow...";  
     else  
     {  
        cout<<"Enter value of x :";  
        cin>>x;  
        temp=first;  
        while(temp->link!=NULL && temp->info!=x)  
        {  
           pred=temp;  
           temp=temp->link;  
        }  
        if(temp->info != x)  
           cout<<"Node not found.";  
        else  
           if( first->info==x)  
            first=first->link;  
           else  
            pred->link=temp->link;  
     }  
  }  
 void main()  
 {  
 first=(struct list *)malloc(10);  
 first=NULL;  
 clrscr();  
 do  
 {  
 clrscr();  
 menu();  
 if(ch==1) insert();  
 if(ch==2) display();  
 if(ch==3) rev();  
 if(ch==4) del();  
  getch();  
 }  
 while(ch!=0);  
 }  
  //Program on Linked list, New node insert at begining position.  
  #include<iostream.h>  
  #include<conio.h>  
  #include<stdlib.h>  
  struct list  
  {  
    int  info;  
    struct list *link;  
  };  
 struct list *node1,*first,*temp;  
 int ch,x;  
  void menu()  
  {  
      cout<<endl<<"Linked List ";  
      cout<<endl<<"=========";  
      cout<<endl<<"1. Insert ";  
      cout<<endl<<"2. Display ";  
      cout<<endl<<"3. Exit ";  
      cout<<endl<<"Enter your choice...";  
      cin>>ch;  
  }  
  void insert()  
  {  
      cout<<"Enter element...";  
      cin>>x;  
      node1 = (struct list *)malloc(10);  
      node1->info = x;  
      node1->link = NULL;  
      if ( first == NULL )  
      {  
         first = node1;  
      }  
      else  
      {  
           node1->link = first;  
           first = node1;  
      }  
  }  
  void display()  
  {  
      cout<<endl<<"Linked List Elements are...";  
      temp = first;  
      while (temp != NULL)  
      {  
           cout<<temp->info<<",";  
           temp = temp->link;  
      }  
  }  
  void main()  
  {  
    first = ( struct list *)malloc(10);  
    first = NULL ;  
    do  
    {  
      clrscr();  
      menu();  
      if (ch==1) insert();  
      if (ch==2) display();  
      getch();  
    }  
    while ( ch != 3 );  
  }  
  //Program on Linked list, New node insert at end.  
  #include<iostream.h>  
  #include<conio.h>  
  #include<stdlib.h>  
  struct list  
  {  
    int  info;  
    struct list *link;  
  };  
 struct list *node1,*first,*temp;  
 int ch,x;  
  void menu()  
  {  
      cout<<endl<<"Linked List ";  
      cout<<endl<<"=========";  
      cout<<endl<<"1. Insert ";  
      cout<<endl<<"2. Display ";  
      cout<<endl<<"3. Exit ";  
      cout<<endl<<"Enter your choice...";  
      cin>>ch;  
  }  
  void insert()  
  {  
      cout<<"Enter element...";  
      cin>>x;  
      node1 = (struct list *)malloc(10);  
      node1->info = x;  
      node1->link = NULL;  
      if ( first == NULL )  
      {  
         first = node1;  
      }  
      else  
      {  
           temp = first;  
           while ( temp->link != NULL )  
                temp = temp->link;  
           temp->link = node1;  
      }  
  }  
  void display()  
  {  
      cout<<endl<<"Linked List Elements are...";  
      temp = first;  
      while (temp != NULL)  
      {  
           cout<<temp->info<<",";  
           temp = temp->link;  
      }  
  }  
  void main()  
  {  
    first = ( struct list *)malloc(10);  
    first = NULL ;  
    do  
    {  
      clrscr();  
      menu();  
      if (ch==1) insert();  
      if (ch==2) display();  
      getch();  
    }  
    while ( ch != 3 );  
  }  
  //Program on Linked list, New node insert so that information field  
  //store in ascending order.  
  #include<iostream.h>  
  #include<conio.h>  
  #include<stdlib.h>  
  struct list  
  {  
    int  info;  
    struct list *link;  
  };  
 struct list *node1,*first,*temp,*succ;  
 int ch,x;  
  void menu()  
  {  
      cout<<endl<<"Linked List ";  
      cout<<endl<<"=========";  
      cout<<endl<<"1. Insert ";  
      cout<<endl<<"2. Display ";  
      cout<<endl<<"3. Exit ";  
      cout<<endl<<"Enter your choice...";  
      cin>>ch;  
  }  
  void insert()  
  {  
      cout<<"Enter element...";  
      cin>>x;  
      node1 = (struct list *)malloc(10);  
      node1->info = x;  
      node1->link = NULL;  
      if ( first == NULL )  
      {  
         first = node1;  
      }  
      else  
        if(node1->info<=first->info)  
        {  
           node1->link = first;  
           first = node1;  
        }  
        else  
        {  
           temp = first;  
           succ =temp->link;  
           while ( temp->link != NULL && succ->info <= node1->info )  
           {  
                temp=temp->link;  
                succ=temp->link;  
           }  
           node1->link=temp->link;  
           temp->link=node1;  
        }  
  }  
  void display()  
  {  
      cout<<endl<<"Linked List Elements are...";  
      temp = first;  
      while (temp != NULL)  
      {  
           cout<<temp->info<<",";  
           temp = temp->link;  
      }  
  }  
  void main()  
  {  
    first = ( struct list *)malloc(10);  
    first = NULL ;  
    do  
    {  
      clrscr();  
      menu();  
      if (ch==1) insert();  
      if (ch==2) display();  
      getch();  
    }  
    while ( ch != 3 );  
  }  
 //Program: To delete a node whose value is given by x from singly Linked list.  
  #include<iostream.h>  
  #include<conio.h>  
  #include<stdlib.h>  
  struct list  
  {  
    int  info;  
    struct list *link;  
  };  
 struct list *node1,*first,*temp,*pred;  
 int ch,x;  
  void menu()  
  {  
      cout<<endl<<"Linked List ";  
      cout<<endl<<"=========";  
      cout<<endl<<"1. Insert ";  
      cout<<endl<<"2. Delete ";  
      cout<<endl<<"3. Display";  
      cout<<endl<<"0. Exit ";  
      cout<<endl<<"Enter your choice...";  
      cin>>ch;  
  }  
  void insert()  
  {  
      cout<<"Enter element...";  
      cin>>x;  
      node1 = (struct list *)malloc(10);  
      node1->info = x;  
      node1->link = NULL;  
      if ( first == NULL )  
      {  
         first = node1;  
      }  
      else  
      {  //New node insert at end of a list.  
           temp=first;  
           while(temp->link!=NULL)  
                temp=temp->link;  
           temp->link = node1;  
      }  
  }  
  void del()  
  {  
   int x;  
     if (first==NULL)  
       cout<<endl<<"Underflow...";  
     else  
     {  
        cout<<"Enter value of x :";  
        cin>>x;  
        temp=first;  
        while(temp->link!=NULL && temp->info!=x)  
        {  
           pred=temp;  
           temp=temp->link;  
        }  
        if(temp->info != x)  
           cout<<"Node not found.";  
        else  
           if( first->info==x)  
            first=first->link;  
           else  
            pred->link=temp->link;  
     }  
  }  
  void display()  
  {  
    if(first==NULL)  
      cout<<endl<<"Linked list empty...";  
    else  
    {  
      cout<<endl<<"Linked List Elements are...";  
      temp = first;  
      while (temp != NULL)  
      {  
           cout<<temp->info<<",";  
           temp = temp->link;  
      }  
    }  
  }  
  void main()  
  {  
    first = ( struct list *)malloc(10);  
    first = NULL ;  
    do  
    {  
      clrscr();  
      menu();  
      if (ch==1) insert();  
      if(ch==2) del();  
      if (ch==3) display();  
      getch();  
    }  
    while ( ch != 0 );  
  }