No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
I'm trying to use for loops to output: 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1 public class Fit1 { public static void main(String args[]) { int side1,side2, side3; for (side1 = 1; side1 <= 3; side1++) { for (side2 … | |
How do I sort 10 random numbers using quick sort with push() and pop() ? | |
#include<iostream> using namespace std; void BubbleSort(int ar[10], int n, int & compare_costs, int & swap_costs) { int t; int swaps=-1; while(swaps) { swaps++; compare_costs++; for(int i=0; i<n-1; i++) if(ar > ar[i+1]) { t=ar; ar=ar[i+1]; ar[i+1]=t; swap_costs=swap_costs+5; } } } int main() { int n, compare_costs, swap_costs; int ar[10]; int *bs … | |
I'm trying to generate 100 random numbers from 1-100 into an array. I can generate the 100 random numbers but don't know how to put it into an array. #include<iostream> using namespace std; int main() { int ar; for(int i=0; i<100; i++) { ar =(rand()%100); cout<<ar<<" "; } } |