#include <iostream.h> #include <conio.h> #include <iomanip.h> int main() { int a=0,b=0,c,d=4,e=1,f=2,g,s=1,n; cout<<"which number do you like to show? "; cin>>n; c=2*n; while (a<n) { while (b<c) { cout<<" "; b++; } b=0; while (e<f) { s=f/2; if (e<=f/2) { cout<<setw(2)<<e; } else { s=f/2; while (1<g) { g=g-1; cout<<setw(2)<<g; } } e++; } e=1; f=f+2; g=(f/2); while (b<c) { cout<<" "; b++; } b=0; c=c-1; cout<<endl; a++; } a=1; b=0; d=4; e=1; c=c+2; f=f-4; g=(f/2); s=1; while (a<2*n) { while (b<c) { cout<<" "; b++; } b=0; while (e<f) { if (e<=f/2) { cout<<setw(2)<<e; } else { while (1<g) { g=g-1; cout<<setw(2)<<g; } } e++; } e=1; f=f-2; g=(f/2); while (b<c) { cout<<" "; b++; } b=0; c=c+1; cout<<endl; a++; } getch(); return 0; }
میزان نظرات تعیین کننده درج توضیحات است
/* ============== 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; }
/* ============== 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>
مقدار نظرات تعیین کننده درج توضیحات خواهد بود
/* ============== Program Description ============= */ /* program name : bedonezarb.cpp */ /* zarbe do adad bedone amale zarb. */ /* ================================================== */ #include <iostream.h> #include <conio.h> main() { int sum=0,a,b; clrscr(); cout<<"enter 1st number"; //input: 1st num cin>>a; cout<<"enter 2nd number"; //input: 2nd num cin>>b; while (a!=0) { sum+=b; a--; } //end: while cout<<"zarbe 2 adad ="<<sum; //output: sum getch(); return 0; } //end: main
/* ============== Program Description ============= */ /* program name : avg_mag.cpp */ /* 10 ad enter avg & makos */ /* ================================================== */ #include <iostream.h> #include <conio.h> main() { const int n=10; int a[n],i,sum=0; float avg; clrscr(); for (i=0;i<n;i++) { cout<<"please enter num"; cin>>a[i]; sum=sum+a[i]; } avg=sum/n; cout<<"avrege is "<<avg<<endl; for (i=(n-1);i>=0;i--) cout<<a[i]<<"-"; getch(); return 0; }