/* ============== Program Description ============= */ /* program name : compnum.cpp */ /* input a number then is it compelet */ /* ================================================== */ #include <iostream.h> #include <conio.h> main() { int num,i=2,sum=1; clrscr(); cout<<"please enter anumber?"; cin>>num; if (num<=0) cout<<"incorrect number"; else while (i<=num/2) { if ((num%i)==0) sum+=i; i++; } //end while if(sum==num) cout<<num<<" is complete."; else cout<<num<<" isn't complete."; getch(); return 0; } //end main
/* ============== Program Description ============= */ /* program name : adadeaval.cpp */ /* miyangil adad avale <100 */ /* ================================================== */ #include <iostream.h> #include <conio.h> int prime(int n); main() { int n,counter=0; float avg=0,sum=0; clrscr(); for (n=2;n<=100;n++) { if (prime (n)==1) { cout<<n<<" "; sum+=n; counter++; } } avg=sum/counter; cout<<endl<<"avrege is "<<avg; getch(); return 0; } //********************************* int prime (int n) { int i; for (i=2;i<=n/2;i++) if ((n%i)==0) return 0; return 1; }
یک جزوه کامل و بی نظیر همراه با آموزش C و مثالهای حل شده و تمرینات بی نظیر
++C
دانلود از اینجا
/* ============== Program Description ============ */ /* program name : 8 vazir.cpp */ /* nahveye garar gereftane 8 vazir */ /* ================================================= */ #include<stdio.h> #define N 8 int Chess(char Arr[N][N],int row); int check(char Arr[N][N],int row,int line); void main(void) { char chess[N][N]={0}; Chess(chess,0); /* The call to the function*/ int i,y; for(i=0;i<N;++i) /*prints the result*/ { printf("\n\t\t\t"); for(y=0;y<N;++y) if(chess[i][y]==0)printf("x "); else printf("%c ",chess[i][y]); } printf("\n"); } int Chess(char Arr[N][N] ,int row) { int line=0; if(row==N)return 1; while(line < N) { if(check(Arr,row,line)) /*check the row*/ { Arr[row][line]='Q'; /*puts a queen on the board*/ if(Chess(Arr,row+1))return 1; /*the recursion*/ Arr[row][line]=0; /*clears the last change if*/ } /*returned 0 from the recursion*/ line++; } return 0; } int check(char Arr[N][N],int row,int line) { /*check just the left size of the board*/ int r,l; r=row; l=line; while(r >= 0 && l >= 0) { if(Arr[r][l]=='Q')return 0; --r; --l; } l=line; r=row; while(l < N && r >= 0) { if(Arr[r][l]=='Q')return 0; ++l; --r; } l=line; r=row; while(r >= 0) { if(Arr[r][l]=='Q')return 0; --r; } return 1; }</body> </html>
مقدار نظرات تعیین کننده درج توضیحات خواهد بود
دوستان عزیزی که در اجرای Turbo C++ 3.0 dos مشکل داشتند می توانند از اینجا نسخه تحت ویندوز را دانلود کنند.
/* ============== Program Description ============= */ /* program name : retabfact.cpp */ /* compute fact with return tab */ /* ================================================== */ #include <iostream.h> #include <conio.h> int fact (int n); main() { int n; clrscr(); cout<<"enter a num -->"; cin>>n; cout<<n<<"!= "<<fact(n); getch(); return 0; } //end main //***************************** int fact (int n) { int f=0; if ((n==0)||(n==1)) return 1; else f=n*fact (n-1); return f; } </body> </html>
/* ============== Program Description ============= */ /* program name : bayretab.cpp */ /* compute bayneri with return tab */ /* ================================================== */ #include <iostream.h> #include <conio.h> int bay (int n); main() { int n; clrscr(); cout<<"enter a number -->"; cin>>n; cout<<"the barneri of "<<n<<" is "; bay (n); getch(); return 0; } //end main //***************************** int bay (int n) { if (n>0) { bay (n/2); cout<<n%2; } }