NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

Wmat/codefonts

From Texas Instruments Wiki
Jump to: navigation, search

<syntaxhighlight lang="cpp">

  1. include <iostream.h>
  2. include <iomanip.h>
  3. include <stdlib.h>
  4. include <time.h>

const c=10; void inputa(int a[ ]); void outputa(int a[ ]); void dosort(int a[ ]); void swap(int &x, int &y); void search(int a[ ]); int dosearch(int a[ ], int b); int main() { int a[c]; time_t seconds; time(&seconds); srand((unsigned int) seconds); inputa(a); outputa(a); cout<<endl; dosort(a); outputa(a); search(a); return 0; } void inputa(int a[ ]) { int i; for(i=0; i<c;i++) { a[i]=rand()%101; } } void outputa(int a[ ]) { int pig; for(pig=0; pig<c;pig++) { cout<<a[pig]<<endl; } } void dosort(int a[ ]) { int j, pig; for(pig=0;pig<c;pig++) { for(j=0;j<c;j++) { if (a[j]>a[pig]) { swap(a[j],a[pig]); } } } } void swap(int &a, int &b) { int temp; temp=a; a=b; b=temp; } void search(int a[ ]) { int b; cout<<"Enter Number to Search for: "; cin>>b; dosearch(a,b); cout<<"The number was found in line number "<<dosearch(a,b)<<endl; } int dosearch(int a[ ], int b) { int high=c; int mid=c/2; int low=-1; int d=0; int line=0; do { if(b>a[mid]) { low=mid+1; mid=(high+low)/2; } else if (b<a[mid]) { high=mid+1; mid=(high+low)/2; } else if(a[mid]==b) { return mid+1; } }while(low<high); return -1; } </syntaxhighlight>

E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Wmat/codefonts here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Wmat/codefonts here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article Wmat/codefonts here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article Wmat/codefonts here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article Wmat/codefonts here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Wmat/codefonts here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Wmat/codefonts here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article Wmat/codefonts here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Wmat/codefonts here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity