Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Qwertyuiop

cpp

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string.h>
#include <ctime>

template <class T>
void swap(T &a, T &b)
{
	T tmp = a;
	a = b;
	b = tmp;
}

void Sort(int **Arr, int N)
{
    std::clog << "CALL Sort(int **Arr, int N)\n"; // DEBUG
	for (int l = 0; l < N; ++l)
	{
		for (int i = 0; i < N - 1; ++i)
		{
			for (int j = i + 1; j < N; ++j)
			{
				if (Arr[l][i] > Arr[l][j])
					swap(Arr[l][i], Arr[l][j]);
			}
		}
	}
}

void Sort(int **Arr, int *Str, int N)
{
	for (int i = 0; i < N - 1; ++i)
	{
		for (int j = i + 1; j < N; ++j)
		{
			if (Str[i] > Str[j])
			{
				swap(Str[i], Str[j]);
				for (int l = 0; l < N; ++l)
					swap(Arr[i][l], Arr[j][l]);
			}
		}
	}
}

int main()
{
	int K, n; // количество и размеры матриц
	std::cout << "Введите размеры матриц (N x N) N: ";
	std::cin >> n;
	std::cout << "\n\nВведите количество матриц K: ";
	std::cin >> K;

	srand(time(NULL));
	FILE * file = fopen("Array.txt", "w");

	for (int k; k < K; ++k)
	{
		std::cout << "\n\n\n";
		int *Str = new int[n];
		int **Arr = new int * [n];

		for (int i = 0; i < n; ++i)
			Arr[i] = new int[n];

		for (int i = 0; i < n; ++i)
		{
			Str[i] = 0;
			for (int j = 0; j < n; ++j)
			{
				Arr[i][j] = rand() % 90 + 10;
				Str[i] += Arr[i][j];
			}
		}

		printf("Матрица Суммы строк\n\n");
		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < n; ++j)
				printf("%4i ", Arr[i][j]);
			printf("%8i \n", Str[i]);
		}

		Sort(Arr, n);
		Sort(Arr, Str, n);

		fprintf(file, "Матрица Суммы строк\n\n");
		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < n; ++j)
				fprintf(file, "%4i ", Arr[i][j]);
			fprintf(file, "%8i \n", Str[i]);
		}
		fprintf(file, "\n\n\n ");

		for (int i = 0; i < n; ++i)
			delete[] Arr[i];
		delete[] Arr;
	}

	fclose(file);
}

[email protected]

cpp

// Jordan Davis, J00560340, 9/10/2017, jordandavis.cpp
// Output basic information
#include <iostream>
using namespace std;
int main()
{
 // Hello World output statement
 cout << "Hello World" << endl;

 // Attention CIS210 Students:
 // Replace SouthPaw's information with your own information
 // for this sectin of output staements #1 - #7.
 cout << "1) My name is: Jordan Davis" << endl;
 cout << "2) My Jag# is: J00560340" << endl;
 cout << "3) The last 4 digits of my Jag# is: 0340" << endl;
 cout << "4) My major is: Electrical Engineering" << endl;
 cout << "5) I am a Junior" << endl;
 cout << "6) My hometown is: Mobile, Al." << endl;
 cout << "7) An application that impresses me is: Uber" << endl;

 return 0;
}

Land Calculation (Cristian Matias)

cpp

#include <iostream>
using namespace std;

int main()
{
 float acre = 43560;  //1 acre = 43560 sq ft
 float land = 391876; // 391876 sq ft

 float total = land / acre;

 cout<<land<<"sq ft = " <<total<< " acres "<<endl;

 return 0;
}

Compile and Execute C++ Online

cpp

// Chase Spitzkopf, J00218378, 11SEP17, Assignment #2
// Assignment 2, Calculate average of 5 test scores then display result to screen.

 #include <iostream>
 #include <iomanip>

 using namespace std;

 int main()
 {
 cout << "1) My name is: Chase Spitzkopf" << endl;
 cout << "2) My Jag# is: J00218378" << endl;
 cout << "3) The last 4 digits of my Jag# are: 8378" << endl;

 double testScore1; 
 double testScore2; 
 double testScore3; 
 double testScore4; 
 double testScore5; 

 cout << "Enter test score 1: ";
 cin >> testScore1; 
 cout << endl;

 cout << "Enter test score 2: ";
 cin >> testScore2; 
 cout << endl;

 cout << "Enter test score 3: ";
 cin >> testScore3; 
 cout << endl;

 cout << "Enter test score 4: ";
 cin >> testScore4; 
 cout << endl;

 cout << "Enter test score 5: ";
 cin >> testScore5; 
 cout << endl;

 cout << "Average test score: " << (70+97.5+100+80+64.5)/5
<< endl;
 cout << endl;

 return 0;
 }

Sum if Two Numbers (Cristian)

cpp

#include <iostream>

using namespace std;

int main()
{
   int num1 = 50;
   int num2 = 100;
   int total = num1 + num2; 
   cout<< total;
   
   return 0;
}

Triangle Pattern (Cristian Matias)

cpp

#include <iostream>

using namespace std;

int main()
{
   int num1 = 50;
   int num2 = 100;
   int total = num1 + num2; 
   cout<< total;
   
   return 0;
}

extreme value theorem at least

cpp

#include <iostream>

using namespace std;

int main()
{
   cout << "Hello World" << endl; 
   
   return 0;
}

Compile and Execute C++ Online

cpp

#include <stdio.h>
int main()
{

int x = 21, y = 0xa, z = 077;

printf("My name is: Jordan Guy.\n", x);
return 0;
}

#include <stdio.h>
int main()
{

int x = 21, y = 0xa, z = 077;

printf("Jordan Guy\n", x);
return 0;
}

#include <stdio.h>
int main()
{

int x = 21, y = 0xa, z = 077;

printf("Integer 1: 5\n", x);
printf("Integer 2: 7\n", x);
printf("Integer 3: 11\n", x);
printf("Integer 4: 15\n", x);
printf("Sum: 38\n", x);
return 0;
}

Programming Challenge 2 CMSC140

cpp

//Nikki Añonuevo
//September 7,2017
//Programming Challenge 4
//Restaurant Bill

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
double mealCost = 88.67;
double tax = 0.0675 ;
double tip = 0.20 ;
int	
doubleTax_MC,
doublebill,
doubletotal_bill,
doubleTip_TB;


//Calculate the tax of the meal cost
double Tax_MC = mealCost * tax;

//Calculate the amount of the bill
double bill = Tax_MC + mealCost;

//Calculate the cost of the tip from bill
double Tip_TB = bill * tip;

//Calculate the total amount of the bill plus tip an tax
double total_bill = bill + Tip_TB + Tax_MC;

//Display the results
cout << setprecision (2) << fixed; 
cout << "Meal Cost: $" << mealCost << endl;
cout << "Tax Amount: $" << Tax_MC << endl;
cout << "Tip: $" << Tip_TB << endl;
cout << "Total Amount: $" << total_bill << endl;

return 0;
}

binary tree traversals

cpp

#include<iostream>
using namespace std;
struct Node
{
	Node *left;
	Node *right;
	int data;
} ;
class bst
{
	Node *root;
	public:
	bst()
	{
		root=NULL;
	}
	
	void insert(int a);
	void inordertrav();
	void inorder(Node *);
	void postordertrav();
	void postorder(Node *);
	void preordertrav();
	void preorder(Node *);
};
void bst::insert(int a)
{
	Node *p=new Node;
	Node *parent;
    p->data=a;
	p->left=NULL;
	p->right=NULL;
	parent=NULL;
	if(root==NULL)
		root=p;
	else
	{
		Node *ptr;
		ptr=root;
		while(ptr!=NULL)
		{
			parent=ptr;
			if(p->data>ptr->data)		
				ptr=ptr->right;
			else
				ptr=ptr->left;
		}	
		if(p->data<parent->data)
			parent->left=p;
		else
			parent->right=p;
	}
}
void bst::inordertrav()
{
	inorder(root);
}
void bst::inorder(Node *ptr)
{
	if(ptr!=NULL)
	{
		inorder(ptr->left);
		cout<<"  "<<ptr->data<<"     ";
		inorder(ptr->right);
	}
}
void bst::postordertrav()
{
	postorder(root);
}
void bst::postorder(Node *ptr)
{
	if(ptr!=NULL)
	{
		postorder(ptr->left);
		postorder(ptr->right);
		cout<<"  "<<ptr->data<<"     ";
	}
}
void bst::preordertrav()
{
	preorder(root);
}
void bst::preorder(Node *ptr)
{
	if(ptr!=NULL)
	{
		cout<<"  "<<ptr->data<<"     ";
		preorder(ptr->left);
		preorder(ptr->right);
	}
}
int main()
{
	bst b;
	b.insert(30);
	b.insert(15);
	b.insert(40);
	b.insert(35);
	b.insert(5);
	b.insert(80);
	b.insert(20); 
	cout<<"inorder"<<endl;
	b.inordertrav();
	cout<<endl<<"postorder"<<endl;
	b.postordertrav();
	cout<<endl<<"preorder"<<endl;
	b.preordertrav();
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.