loading...
مرجع مهندسی نرم افزار
آخرین ارسال های انجمن
حامد شیرزاد بازدید : 468 جمعه 27 آبان 1390 نظرات (0)
An Example of Exception Handling
#include <;iostream>
using namespace std;
int main()
{
    unsigned int TypeOfLoan = 0;
    const char *LoanType[] = { "Personal",
                "Car",
                "Furniture",
                "Musical Instrument",
                "Boat" };
    try {
        cout <;< "Enter the type of loann";
        for(int i = 0; i < 4; i++)
            cout <;< i + 1 << ") " << LoanType[i] << endl;
        cout <;< "Your choice: ";
        cin >;> TypeOfLoan;
 
        if( TypeOfLoan <; 1 || TypeOfLoan > 5 )
            throw "Number out of rangen";
        cout << "nType of Loan: " << LoanType[TypeOfLoan] << endl;
    }
    catch(const char* Msg)
    {
        cout <;< "Error: " << Msg << endl;
    }
    catch(...)
    {
        cout <;< "nSomething went wrongnn";
    }
 
    return 0;
}
حامد شیرزاد بازدید : 796 جمعه 27 آبان 1390 نظرات (0)
/*
    BubbleSort.h
 
    USAGE:
        create an integer array and determine the amount of elements in the
        array. then Call BubbleSort with the array's pointer and the amount of
        elements in the array. BubbleSort will then return a pointer to a sorted
        array.
         
    John Shao
     
********************************************************************************
    This work is hereby released into the Public Domain. To view a copy of the
    public domain dedication, visit
    http://creativecommons.org/licenses/publicdomain/
     
    or send a letter to
     
    Creative Commons
    559 Nathan Abbott Way
    Stanford, California 94305
    USA.
*******************************************************************************/
 
int* BubbleSort(int* arr,int size)
{
    int swap;
 
    while(size>0)
    {
        for(int i=0;i<size-1;i++)
        {
            if(arr[i]>;arr[i+1])
            {
                swap=arr[i];
                arr[i]=arr[i+1];
                arr[i+1]=swap;
            }
        }
        --size;
    }
 
    return arr;
}
 
/******************************************************************************/
/*                   The Following is a Test Program                          */
/******************************************************************************/
/*
#include<;iostream>
 
int main()
{
        int*data=new int[10];
        for(int i=0;i<10;i++)
        {
            std::cout<;<'>';
            std::cin>;>data[i];
            std::cin.get();
        }
        data=BubbleSort(data,10);
        for(int i=0;i<10;i++)
            std::cout<;<data[i]<<' ';
 
        std::cout<;<std::flush;
        std::cin.get();
        delete [] data;
        return 0;
}
*/
حامد شیرزاد بازدید : 770 جمعه 27 آبان 1390 نظرات (0)
#include <;stdio.h>    /* sprintf */
#include <;string.h>   /* strcat */
 
/*
** gotoxy() Implementation in the *nix environment
**
** Note: I've heard the curses library can be useful
** when trying to implement the handy DOS-only tools of
** gotoxy() and clrscr() using move() and initscr().
** Though, there is a way to write your own gotoxy()
** in the Linux environment. This topic isn't discussed
** often, so I'd like to bring a few new ideas to the table.
**
** Concept: We will use two ANSI C standard functions
** to accomplish our task. We will use specific
** string manuvers, according to the man pages, that
** will allow us to execute each part of the program.
*/
void gotoxy(int x, int y) {
        char essq[100];     /* String variable to hold the escape sequence */
        char xstr[100];     /* Strings to hold the x and y coordinates */
        char ystr[100];     /* Escape sequences must be built with characters */
 
        /*
        ** Convert the screen coordinates to strings
        */
        sprintf(xstr, "%d", x);
        sprintf(ystr, "%d", y);
 
        /*
        ** Build the escape sequence (vertical move)
        */
        essq[0] = '';
        strcat(essq, "33[");
        strcat(essq, ystr);
 
        /*
        ** Described in man terminfo as vpa=E[%p1%dd
        ** Vertical position absolute
        */
        strcat(essq, "d");
 
        /*
        ** Horizontal move
        ** Horizontal position absolute
        */
        strcat(essq, "33[");
        strcat(essq, xstr);
        /* Described in man terminfo as hpa=E[%p1%dG */
        strcat(essq, "G");
 
        /*
        ** Execute the escape sequence
        ** This will move the cursor to x, y
        */
        printf("%s", essq);
}

تعداد صفحات : 46

درباره ما
به نام آنکه جان را فکرت آموخت در این وبلاگ سعی می شود به صورت تخصصی به مباحث مربوط به مهندسی نرم افزار به خصوص برنامه نویسی کامپیوتری پرداخته شود. مدیر وبلاگ : حامد شیرزاد
اطلاعات کاربری
  • فراموشی رمز عبور؟
  • آمار سایت
  • کل مطالب : 431
  • کل نظرات : 9
  • افراد آنلاین : 1
  • تعداد اعضا : 109
  • آی پی امروز : 63
  • آی پی دیروز : 185
  • بازدید امروز : 1,580
  • باردید دیروز : 718
  • گوگل امروز : 0
  • گوگل دیروز : 0
  • بازدید هفته : 2,629
  • بازدید ماه : 5,280
  • بازدید سال : 24,381
  • بازدید کلی : 792,909
  • کدهای اختصاصی

    قالب وبلاگ