ARRAY.rar

  • FARDEEN.SADEGHI
    了解作者
  • C++
    开发工具
  • 1KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 2
    下载次数
  • 2015-11-20 03:57
    上传日期
dynamic array using class principle
ARRAY.rar
  • ARRAY.CPP
    3.4KB
内容介绍
#include<iostream.h> #include<conio.h> #include<stdlib.h> void insert(int x[10],int); void del(int x[],int); void sort(int x[],int); void search_seq(int x[],int); void bin_search(int x[],int); void show(int x[],int); void my_delay(); void main_menu(); //*************** int main(){ main_menu(); getch(); return 0; } //*************** void my_delay() { char x; gotoxy(50,25); cout<<"Press any key to continue..."; getch(); main_menu(); } //***************** void show(int x[],int a){ clrscr(); for(int i=0;i<a;i++) { cout<<"Index "<<i+1<<" of array is "<<x[i]<<"\n"; } my_delay(); } //****************** void bin_search(int x[],int len){ int top,low; top=len; low=0; int item; clrscr(); cout<<"Enter number for search:" ; cin rel='nofollow' onclick='return false;'>>item; while(low<=top){ int mid=(low+top)/2; if(x[mid]<item) low=mid+1; else if(x[mid]>item) top=mid-1; else if (x[mid]==item) { clrscr(); cout<<"your result search is index "<<mid; my_delay(); } } clrscr(); cout<<"not found"; my_delay(); } //************** void sort(int x[],int len){ for(int i=0;i<len-1;i++) for(int j=0;j<i;j++) if (x[j]<x[j+1]) { int temp=x[j]; x[j]=x[j+1]; x[j+1]=temp; } my_delay(); } //******************** void search_seq(int x[],int a) { int item ; clrscr(); cout<<"Enter value for search:" ; cin>>item; for(int i=0;i<a;i++) if (item==x[i]) { clrscr(); cout<<"your result search is index "<<i; my_delay(); } clrscr(); cout<<"not found"; my_delay(); } //********************************* void insert(int x[],int a) { clrscr(); for(int i=0;i<a;i++) { clrscr(); x[i]=0; cout<<"Enter a number for index "<<i<< " of array:"; cin rel='nofollow' onclick='return false;'>>x[i]; } clrscr(); cout<<"Insert is success"; my_delay(); } //***************** void del(int x[],int a){ char ch; int item; clrscr(); cout<<"Enter a value for delete:"; cin>>item; for(int i=0;i<a;i++) if (*(x+i)==item) { clrscr(); cout<<"Are you sure ? y=yes n=no:::"; cin rel='nofollow' onclick='return false;'>>ch; exit; } if (ch=='y'){ *(x+i)=0; my_delay(); } else { clrscr(); cout<<"Abort by user..."; my_delay(); } } //************************** void exit(){ char x; clrscr(); gotoxy(20,12); cout<<"programing by :: fardeen sadeghi"; cin>>x; exit(0); } //************************** void main_menu(){ int len=10,an,*p; p=new int[10]; clrscr(); gotoxy(15,6); cout<<"Wellcome to main menu"; gotoxy(20,12); cout<<"1.Insert item"; gotoxy(20,14); cout<<"2.Delete item"; gotoxy(20,16); cout<<"3.Sort item"; gotoxy(20,18); cout<<"4.Search sequantioal"; gotoxy(20,20); cout<<"5.Binary search item"; gotoxy(20,22); cout<<"6.Show item"; gotoxy(20,24); cout<<"7.Exit"; gotoxy(20,30); cout<<"Inser your choice:"; cin>>an; switch(an){ case 1: insert(p,len); case 2: del(p,len); case 3: sort(p,len); case 4: search_seq(p,len); case 5: bin_search(p,len); case 6: show(p,len); case 7: exit(); } } //*********************
评论
    相关推荐
    • class2021Spring
      class2021Spring
    • class2021Spring
      class2021Spring
    • class2021Spring
      class2021Spring
    • classnames.zip
      classnames 是一个简单的 JavaScript 工具包用来有条件的将不同的 classNames 联合在一起。示例代码:classNames('foo', 'bar'); // => 'foo bar' classNames('foo', { bar: true }); // => 'foo bar' ...
    • ClassManager:js
      #Lava.ClassManager 的独立版本 请参阅文档: : ##注意力! 独立的 ClassManager 是自包含的(它不依赖于 MooTools,就像主框架一样)。 ##用法示例 您可以要求( lib/class_manager.js )或直接在浏览器中...
    • class2021spring
      class2021弹簧
    • class2021Spring
      class2021Spring
    • class2021spring
      class2021弹簧
    • Generator_Class_BD.rar
      Generador de clases, capa de datos y negocio para sql server
    • Class1.rar
      This is a sample class