برچسب‌ها

۱۳۸۸ دی ۲, چهارشنبه

برنامه تبدیل روز و ماه و سال شمسی به میلادی

توجه: این برنامه به زبان سی پلاس پلاس میباشد

// taghvim.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "resource.h"

#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text

// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;

// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_TAGHVIM, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);

// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}

hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TAGHVIM);

// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return msg.wParam;
}



//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TAGHVIM);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_TAGHVIM;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

return RegisterClassEx(&wcex);
}

//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;

hInst = hInstance; // Store instance handle in our global variable

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

if (!hWnd)
{
return FALSE;
}

ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);

return TRUE;
}

//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}

Coding by HOMAN ESTAKI

۱۳۸۸ آذر ۲۸, شنبه

برنامه ای که مضارب 5 قبل از عددی را میدهد

int main()
{
int n,i,t;
printf ("please insert a natural number :");
scanf("%d",&n);
t=n%5;
for(i=n-t;i>=0;i--)
{
i=i-5;
if(i<0)>
printf ("%d\t",i);
}
getch();
}

برنامه ای که اعداد صحیح بین دو عدد دریافتی از کاربر را نمایش میدهد

int main()
{
unsigned int i=1,a,b;
printf("insert a:");
scanf("%d",&a);
printf("insert b:");
scanf("%d",&b);
if(a
{
for(i=a;i<=b;i++)
printf(" %d ",i);
}
if(a>b)
{
for(i=b;i<=a;i++)
printf(" %d ",i);
}
else printf("0");
getch();
}

برنامه ای که عددی را دریافت اعداد فرد قبل آنرا نمایش میدهد

int main()
{
unsigned int i=1,n;
printf("insert n:");
scanf("%d",&n);
for(i=n;i<=n;i--)
{
i=i-1;if(i==0)
break;
printf(" %d ",i);
}
getch();
}

۱۳۸۸ آذر ۲۱, شنبه

برنامه محاسبه ی محیط و مساحت دایره با استفاده از یک تابع نوشته شده

float m(float);
float k;
void main()
{
float x;
float r;
printf("enter radius :");
scanf("%f",&r);
x=m(r);
printf("mohit=%.2f, masahat=%.2f",x,k);
getch();
}
/*-----------------------------*/
float m(float r)
{
int s;
s=2*3.14*r;
k=3.14*r*r;
return s;
}
coding by Mr.CHIZARI

جدول ضرب 10در10

int main()
{
int i,j;
for(i=1;i<=10;i++)
for(j=1;j<=10;j++)
printf("%d\t",i*j);
printf("\n");
getch();
}

برنامه ایکه 3 عدد را دریافت و مشخص میکند کدام بزرگتر و چندمین عدد است

int main()
{float a,b,c;
printf("pleas isert 3 number to compare :");
printf("insert a :");
scanf("%f",&a);
printf("insert b :");
scanf("%f",&b);
printf("insert c :");
scanf("%f",&c);
if(a>c && a>b)
printf("the large number is the first one (a)");
if(c>a && c>b)
printf("the large number is the third one (c)");
if(b>a && b>c)
printf("the large number is the second one (b)");
getch();
}

برنامه که اعداد اول قبل از عدد دریافتی را نمایش میدهد

void main()
{
int i,j,n,s=0;
printf("enter a number : ");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
for(j=2;j<=i/2;j++)
{
if(i%j==0)
s++;
}
if(s==0)
printf("%4d",i);
s=0;
}
getch();
}

coding by Mr.Chizari

۱۳۸۸ آذر ۱۵, یکشنبه

برنامه ضرب و جمع دو آرایه

int main()
{
int x[5],y[5],sum[5],m[5],i;
for(i=0;i<5;i++)
{ printf("Enter array[%d]",i);
scanf("%d",&x[i]);}
printf("\n");
for(i=0;i<5;i++)
{ printf("Enter array[%d]",i);
scanf("%d",&y[i]);}
for(i=0;i<5;i++){
printf("\n");
sum[i]=x[i]+y[i];
m[i]=x[i]*y[i];
printf("%d=sum %d=multiply",sum[i],m[i]);}
getch();
}

برنامه ای که زوج و فرد بودن عددی را نمایش میدهد

int main()
{
int n;
printf("please insert a number:");
scanf("%d",&n);
if(n%2==0)
printf("it is even");
else printf("it is odd");
getch();
}

برنامه ای که مربع n عدد را میدهد

int main()
{
int x, complex = 0, z = 0;
char answer = 'y';
while(answer == 'y')
{printf("\n\nEnter a number:");
scanf("%d",&x);
complex += x*x;
z ++;
printf("\n\n Do you want to continue?(y/n):");
answer = getche(); }
printf("\n\ncomplex of square is:%d",complex);
getch();
}

برنامه ای که تعداد حروف جمله ای را مشخص میکند

int main()
{
char x;
int y;
printf("insert your statement :\n");
for(y = 0; (x = getche())!='\r' ; y++) ;
printf("\n the letter of your statement is:%d",y) ;
getch();
}

برنامه ای که تعداد حروف و کلمه در جمله را مشخص میکند

int main()
{
int a = 0, b = 0;
char x;
printf("\n Enter a statement(ENTER):");
while((x = getche()) != '\r'){
a ++;
if(x == ' ')
b ++;
}
printf("\nleter=%d, word=%d", a-b, b+1);
getch();
return 0;
}

برنامه ای که عددی را دریافت و تا 0 انرا چاپ میکند

int main()
{
unsigned int i=1,n;
printf("insert n:");
scanf("%d",&n);
for(i=n;i<=n;i--)
printf(" %d ",i);
getch();
}

برنامه ای که فاکتوریل اعداد را میدهد

unsigned long myfactorial(int) ;
int main()
{
int s ;
printf(" enter a plus sign number:");
scanf("%d", &s);
printf("\n your number is =%d",s);
printf("factorial is = %1d",myfactorial(s));
getch();
return 0;
}

/*_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_*/


unsigned long myfactorial(int a)
{
if(a != 0)
return(a * myfactorial(a - 1)) ;
return 1 ;
}

۱۳۸۸ آذر ۱۴, شنبه

برنامه ای که تعداد ارقام یک عدد را میدهد

int main()
{
char x;
int y;
printf("insert a number :\n");
for(y = 0; (x = getche())!='\r' ; y++) ;
printf("\n the digit of your number is:%d",y) ;
getch();
}

برنامه تبدیلماه و سال به چندمین روز از سال

int main()
{
int m,d,n;
printf("enter month(m) and day(d)");
printf("\ninsert m:");
scanf("%d",&m);
printf("\ninsert d:");
scanf("%d",&d);
if(m<=6)
{n=(m-1)*31+d;
printf("\nnumber of day's year=%d",n);}
else
{n=(m-1)*30+6+d;
printf("\nnumber of day's year=%d",n);}
getch();
}

برنامه ی تبدیل روز به ساعت . دقیقه و ثانیه

int main()
{
int day,h,min,s;
printf("please insert your favorite number of day :\n\n");
scanf("%d",&day);
h=day*24;
min=h*60;
s=min*60;
printf("\n\n\n%d day is: \n\n%d hours and \n\n%d minutes \n\n%d seconds",day , h , min , s);
getch();
}

برنامه ی پرتاب تاس با حلقه ی switch

int game(void);
void main()
{
randomize();
int x,y;
int a1=0,a2=0,a3=0,a4=0,a5=0,a6=0;
int b1=0,b2=0,b3=0,b4=0,b5=0,b6=0;
while(1)
{
printf("\npress any key to strat the game...\n");
getch();
clrscr();
x=game();
y=game();
printf("\n\tthe first number = %d and second = %d\n\n",x,y);
switch(x)
{
case 1:
a1++;
printf("number of 1 = %d\n",a1);
break;
case 2:
a2++;
printf("number of 2 = %d\n",a2);
break;
case 3:
a3++;
printf("number of 3 = %d\n",a3);
break;
case 4:
a4++;
printf("number of 4 = %d\n",a4);
break;
case 5:
a5++;
printf("number of 5 = %d\n",a5);
break;
case 6:
a6++;
printf("number of 6 = %d\n",a6);
break;
}//end of switch
switch(y)
{
case 1:
b1++;
printf("number of 1 = %d\n",b1);
break;
case 2:
b2++;
printf("number of 2 = %d\n",b2);
break;
case 3:
b3++;
printf("number of 3 = %d\n",b3);
break;
case 4:
b4++;
printf("number of 4 = %d\n",b4);
break;
case 5:
b5++;
printf("number of 5 = %d\n",b5);
break;
case 6:
b6++;
printf("number of 6 = %d\n",b6);
break;
}//end of switch
}//end of while
}//end of main
//************************************************
int game(void)
{
int x;
x=random(6)+1;
return x;
}
Coding by Mr.CHIZARI

برنامه مشخص کننده اینکه عددی بر 3 یا 7 بخشپذیر است یا نه

int main()
{
int x;
printf("insert a number:");
scanf("%d",&x);
if(x%3==0)
printf("\nthe number on 3 is true");
else printf("\nthe number on 3 is false");
if(x%7==0)
printf("\n\nthe number on 7 is true");
else printf("\n\nthe number on 7 is false");
getch();
}

برنامه ی نمایش مضرب 5 عددی

int main()
{
int a,b;
printf ("please insert a natural number :");
scanf("%d",&a);
b=a%5;
if(b==0)
{printf ("it is even ");}
else
{printf("odd");}
getch();
}

برنامه نمایش اعداد 0-100


int main()
{
int i=1;
for(i=1;i<=100;i++)
{printf(" %d ",i);
if(i==101) break;}
getch();
}

برنامه ای که علامت عدد را مشخص کند

int main()
{int a;
printf("insert a number:");
scanf("%d",&a);
if(a>0)
printf("it is plus");
if(a<0)
printf("it is minus");
getch();
}

برنامه ای که اسم کاربر را بگیرد در صورت وجود سلام در غیر اینصورت ناشناس اعلام کند

void main()
{
char name[50];
printf("Please insert your user name:\n\n");
scanf("%s",name);
if(strcmpi(name,"hasan")==0strcmpi(name,"ali")==0)
printf("\n\n<<>>");
else printf("\n\n>>>Unknow<<<");
getch();
}

۱۳۸۸ آذر ۱۳, جمعه

string.h

_fmemccpy
_fstrset strdup
_fmemchr
_fstrspn
strdup
_fmemcmp
_fstrstr strerror
_fmemcpy
_fstrtok
_strerror
_fmemicmp
_fstrupr
stricmp
_fmemset
memccpy
strlen
_fstr*
memchr
strlwr
_fstrcat
memcmp
strncat
_fstrchr
memcpy
strncmp
_fstrcmp
memicmp
strncmpi
_fstrcpy
memmove
strncpy
_fstrcspn
memset
strnicmp
_fstrdup
movedata
strnset
_fstricmp
movmem
strpbrk
_fstrlen
setmem
strrchr
_fstrlwr
stpcpy
strrev
_fstrncat
strcat
strset
_fstrncmp
strchr
strspn
_fstrncpy
strcmp
strstr
_fstrnicmp
strcmp
strtok
_fstrnset
strcmpi
strupr
_fstrpbrk
strcoll
strxfrm
_fstrrchr
strcpy
_fstrrev
strcspn

math.h

abs
acos, acosl
asin, asinl
atan, atanl
atan2, atan2l
atof, _atold
cabs, cabsl
ceil, ceill
cos, cosl
cosh, coshl
exp, expl
fabs, fabs
floor, floorl
fmod, fmodl
frexp, frexpl
hypot, hypotl
labs
ldexp, ldexpl
log, logl
log10, log101
_matherr,_matherrl
modf, modfl
poly, polyl
pow, powl
pow10, pow10l
sin, sinl
sinh, sinhl
sqrt, sqrtl
tan, tanl
tanh, tanhl

conio.h

cgets
clreol
clrscr
cprintf
cputs
cscanf
delline
getch
getche
getpass
gettext
gettextinfo
gotoxy
highvideo
inp
inport
inportb
inpw
insline
kbhit
lowvideo
movetext
normvideo
outp
outport
outportb
outpw
putch
puttext
_setcursortype
textattr
textbackground
textcolor
textmode
ungetch
wherex
wherey
window

stdlib.h

abort
labs
realloc
abs
ldiv
_rotl
atexit
lfind
_rotr
atof
_lrotl
_searchenv
atoi
_lrotr
_searchstr
atol
lsearch
_splitpath
bsearch
ltoa
srand
calloc
_makepath
strtod
_crotr
malloc
strtol
div
max
_strtold
ecvt
mblen
strtoul
exit
mbstowcs
swab
_exit
mbtowc
system
fcvt
min
time
free
putenv
ultoa
_fullpath
qsort
wcstombs
gcvt
rand
wctomb
getenv
random
itoa
randomize

stdio.h

clearerr

_fstrncpy
spawnlp
fclose
ftell
spawnlpe
fcloseall
fwrite
spawnv
fdopen
getc
spawnve
feof
getchar
spawnvp
ferror
gets
spawnvpe
fflush
getw
sprintf
fgetc
_pclose
sscanf
fgetchar
perror
strerror
fgetpos
_popen
_strerror
fgets
printf
strncpy
fileno
putc
tempnam
flushall
putchar
tmpfile
fopen
puts
tmpnam
fprintf
putw
ungetc
fputc
remove
unlink
fputchar
rename
vfprintf
fputs
rewind
vfscanf
fread
rmtmp
vprintf
freopen
scanf
vscanf
fscanf
setbuf
vsprintf
fseek
setvbuf
vsscanf
fsetpos
spawnl
_fsopen
spawnle

۱۳۸۸ آذر ۱۲, پنجشنبه

برنامه ی محاسبه ی مساحت و محیط دایره

float main()
{
float r,pi=3.14,s,p;
printf ("please insert radius :");
scanf("%f",&r);
s=pi*r*r ;
p=2*pi*r ;
printf("area=%.2f periphery=%.2f",s,p);
getch();
}

برنامه ی محاسبه ی مقلوب عدد 3 رقمی

int main()
{
int n,a,d1,d2,d3,s;
printf("please insert a 3 digit number whit dot sign in end :");
scanf("%d%",&n);
a=n/10;
d1=a/10;
d2=a%10;
d3=n%10;
s=(d3*100)+(d2*10)+d1;
printf("anagram of the number is:%d",s);
getch();
}

برنامه ی محاسبه ی مساحت مثلث با کمک محیط آن


float main()
{
float a,b,c,s,p;
printf("for calculating surface of triangle please insert the asked thing");
printf("\n\ninsert a:\n");
scanf("%f",&a);
printf("\n\ninsert b:\n");
scanf("%f",&b);
printf("\n\ninsert c:\n");
scanf("%f",&c);
p=(a+b+c)/2;
sqrt(s=p*(p-a)*(p-b)*(p-c));
printf("\n\n\nTHE Surface IS: ");
printf("%.2f",s);
getch();
}

برنامه ی تابع درجه 2


main()
{
float x1,x2,d,a,b,c;
printf("\nEnter a:");
scanf("%f",&a);
printf("\nEnter b:");
scanf("%f",&b);
printf("\nEnter c:");
scanf("%f",&c);
d= b*b-4*a*c;
if(d==0)

printf("\n your asked question has 2 roots wich are equal\n x1=x2=%f",-b/(2*a));
else
if(d<0)
printf("\n your asked question has No root");
else
{
x1= (-b+sqrt(d))/(2*a);
x2= (-b-sqrt(d))/(2*a);
printf("\n your asked question has 2 roots wich are\n x1=%f , x2=%f",x1,x2);
}
getch();
}
Coding by ARAHIK ZADORIAN