کامپیوتر

بایگانی
آخرین مطالب
  • ۰
  • ۰

#include "stdafx.h"

#include "iostream"

using namespace std;

int main()

{

int n = 44;

cout <<"n is:"<<endl<< n << endl << &n << endl;

int* p = &n;

cout <<"p is:"<<endl<< p << endl << &p << endl << *p<<endl;

int** k = &p;

cout << "k is:" << endl << k << endl << &k << endl << *k << endl << **k << endl;

system("pause");

    return 0;

}


  • علی دوران
  • ۰
  • ۰

برنامه ای بنویسید که 2000 عدد بین 10000 و 20000 به صورت راندوم تولید کند و و در تابعی آنها را مرتب کند و عددی از کاربر گرفته و در تابعی دیگر بین اعداد به دنبال آن بگردد و در صورت وجود اعلام کند و در صورتیکه که کاربر موافق بود در تابعی دیگر همه اعداد را چاپ کند

#include "stdafx.h"

#include "iostream"

#include "conio.h"

#include "stdlib.h"

#include "time.h"

using namespace std;

//alidoran

void sorting(int[], int);

void search(int[], int, int,int);

void print(int[], int);

int main() {

int x[2000], size = 0, searchnumber , countnumber=0;

srand(time(0));

for (int i = 0; i<2000; i++)

x[i] = ((rand() % 10000) + 10001);

countnumber =  sizeof x/sizeof 4;

sorting(x, size);

cout << "please enter your search number:";

cin >> searchnumber;

search(x, size, searchnumber , countnumber);

print(x, size);

system("pause");

return 0;

}

void sorting(int so[], int size)

{

int temp, j = 0;

for (int i = 0; i < 2000; i++) {

j = i;

for (j; j < 2000; j++) {

if (so[i] > so[j])

{

temp = so[i];

so[i] = so[j];

so[j] = temp;

}

}

}

}

void search(int numbers[], int size, int search, int count)

{

int low = 0, hi = (count - 1),mid;

while (low <= hi) {

mid = ((low + hi) / 2);

if (numbers[mid] == search)

{cout << "number is available" << endl; 

break;

}

if (numbers[mid] < search) low = mid+1;

else hi = mid-1;

}

system("pause");

}

void print(int numbers[], int size)

{

int q;

cout << "do you want to see numbers?"<<"if yes enter 1 or no another key";

cin >> q;

if (q == 1) {

for (int i = 0; i < 2000; i++)

cout << numbers[i] << "\t";

}

}




  • علی دوران
  • ۰
  • ۰

فایل متنی

فایل cpp

#include "stdafx.h"

#include "iostream"

#include "cmath"

using namespace std;

//alidoran

int main() {

for (float n=0; n < 2; n += 0.2) {

for (float b=0; b < 2; b += 0.2) {

cout << pow(b, n)<<"\t"<<exp(n*log(b))<<endl;

}

}

system("pause");

return 0;

}

  • علی دوران
  • ۰
  • ۰

فایل متنی

فایل cpp

#include "stdafx.h"

#include "iostream"

#include "cmath"

using namespace std;

//alidoran

int main()

{

for (float x = 0; x < 2; x += 0.2) {

cout <<"cos^2("<<x<<")+sin^2("<<x<<")="<< pow(cos(x), 2)+ pow(sin(x) , 2)<< endl;

}

system("pause");

return 0;

}

  • علی دوران
  • ۰
  • ۰

فایل متنی

فایل cpp

#include "stdafx.h"

#include "iostream"

#include "cmath"

using namespace std;

//alidoran

int main()

{

for (float x = 0; x < 2; x += 0.2) {

cout <<"cos 2*"<<x<<" = "<<cos(2 * x) << "\t" <<"2*(cos^2)("<<x<<")-1= "<<2*pow(cos (x),2)-1 <<endl;

}

system("pause");

}

  • علی دوران
  • ۰
  • ۰

فایل متنی

فایل cpp 


#include "stdafx.h"

#include "iostream"

using namespace std;

//alidoran

int main() {

       int x, y , z=1;

       cout << "please enter two number"<<endl;

       cin >> x >>y;

       while (z > 0) {

              z = x % y;

              x = y;

              y = z;

       }

       cout << "your answer is : " << x << endl;

       system("pause");

       return 0;

       }

  • علی دوران
  • ۰
  • ۰

فایل متنی

فایل cpp

#include "stdafx.h"

#include "iostream"

using namespace std;

//alidoran

int main() {

       int x, y=0;

       cout << "please input your number" << endl;

       cin >> x;

       while ((y*y) <= x)

              y++;

       cout <<"answer is : "<< y - 1<<endl;

       system("pause");

       return 0;

}

  • علی دوران
  • ۰
  • ۰

فایل متنی

فایل cpp

#include "stdafx.h"

#include "iostream"

using namespace std;

//alidoran

int main() {

int x,y=0;

cout << "please enter your number : ";

cin >> x;

while (x > 0) {

y += (x % 10);

x /= 10;

y *= 10;

}

cout <<"mirror of your number is : "<< y/10<<endl;

system("pause");

return 0;

}

  • علی دوران
  • ۰
  • ۰


#include "stdafx.h"

#include "iostream"

using namespace std;

//alidoran

int main() {

       int x,y,z=0,t=0;

       cout << "please input two number"<<endl;

       cin >> x>>y;

       cout << "calculate "<<x<<"/"<<y<<endl;

       while (t < (x-y)){

              z++;

              t += y;

       }

       cout <<"divisor is : "<< z << endl <<"quotient is : "<< x - t << endl;

       system("pause");

       return 0;

}

  • علی دوران
  • ۰
  • ۰

فایل متنی

فایل cpp

#include "stdafx.h"

#include "iostream"

using namespace std;

//alidoran

int main() {

int x, s=0;

cout << "please enter your nember";

cin >> x;

do {

s += (x*x);

x -= 1;

}

while (x > 0);

cout << s;

system("pause"); return 0;

}

  • علی دوران