convert c 2b 2b to mips assembly code online

Solutions on MaxInterview for convert c 2b 2b to mips assembly code online by the best coders in the world

showing results for - "convert c 2b 2b to mips assembly code online"
Rebeca
20 Jan 2021
1
2#include <iostream>
3
4using namespace std;
5
6void heapify(int arr[], int n, int i)
7{
8	int largest = i; 
9	int l = 2 * i + 1;
10	int r = 2 * i + 2; 
11
12	if (l < n && arr[l] > arr[largest])
13		largest = l;
14
15	if (r < n && arr[r] > arr[largest])
16		largest = r;
17
18	if (largest != i) {
19		swap(arr[i], arr[largest]);
20
21		heapify(arr, n, largest);
22	}
23}
24
25void deleteRoot(int arr[], int& n)
26{
27
28	int lastElement = arr[n - 1];
29
30	
31	arr[0] = lastElement;
32
33
34	n = n - 1;
35
36	heapify(arr, n, 0);
37}
38
39
40void printArray(int arr[], int n)
41{
42	for (int i = 0; i < n; ++i)
43		cout << arr[i] << " ";
44	cout << "\n";
45}
46int main()
47{
48	
49	int arr[] = { 10, 5, 3, 2, 4 };
50
51	int n = sizeof(arr) / sizeof(arr[0]);
52
53	deleteRoot(arr, n);
54
55	printArray(arr, n);
56
57	return 0;
58}
59
Marta
08 Oct 2016
1#include <stdio.h>
2int main() {
3int i;
4int sum = 0;
5for (i=0; i<=100; i++)
6sum = sum + i*i;
7printf("The sum from 0 to 100 is %d\n",sum);
Kelsey
17 Jan 2018
1# Not sure what to do now? Enter your mips code here