#include<iostream>
using namespace std;
int main()
{
int n;
int i, j = 0, k = 1;
cout<<"\n Enter a positive integer: ";
cin>>n;
int size = n, matrix[n][n];
while(k <= n * n)
{
for(i = j; i < size; i++)
{
matrix[j][i] = k++;
}
for(i = j + 1; i < size; i++)
{
matrix[i][size - 1] = k++;
}
for(i = size - 2; i >= j; i--)
{
matrix[size - 1][i] = k++;
}
for(i = size - 2; i > j; i--)
{
matrix[i][j] = k++;
}
j++, size = size - 1;
}
if(!n % 2)
{
matrix[(n + 1) / 2] [(n + 1) / 2] = n * n;
}
for(i = 0; i < n; i++)
{
for(int l = 0; l < n; l++)
{
cout<<matrix[i][l] <<"\t";
}
cout<<"\n";
}
return 0;
}
OUTPUT
Enter a positive integer: 6
1 2 3 4 5 6
20 21 22 23 24 7
19 32 33 34 25 8
18 31 36 35 26 9
17 30 29 28 27 10
16 15 14 13 12 11
In C++ Make a program that takes a positive integer 'n' and write an n x...
Java program The file enrollments.txt is a text file with each line containing a positive integer that represents the enrollment in a section of CIS 103. The highest value is 36. Write a program to read the data from the file into an array, then calculate and display the number of sections, the average class size, the minimum class size, and the maximum class size. enrollments.txt 36 36 36 34 35 25 34 31 29 19 35 33 36 32...
Write a C or C++ program A6pc(pp) that accepts one command line argument which is an integer n between 2 and 6 inclusive. Generate a string of 60 random upper case English characters and store them somewhere (e.g. in a char array). Use pthread to create n threads to convert the string into a complementary string (‘A’<->’Z’, ‘B’<->’Y’, ‘C’<->’X’, etc). You should divide this conversion task among the n threads as evenly as possible. Print out the string both before...
Therefore, for this program you will read the data in the file named weatherdata_2.txt into arrays for the wind speed and for the temperature. You will then use the stored data to calculate and output the average wind speed and the average temperature. Create a constant with a value of 30 and use that to declare and loop through your arrays and as a divisor to produce your averages. Here is the data file (below). 1. 14 25 2. 12...
1. The service departments at Tionesta Ford Lincoln Mercury and Sheffield Motors Inc., two of the four Applewood Auto Group dealerships, were both open 24 working days last month. Listed below is the number of vehicles serviced last month at the two dealerships. Construct dot plots and report summary statistics to compare the two dealerships. Tionesta Ford Lincoln Mercury Friday Saturday Thursday Wednesday Tuesday Monday 26 28 39 27 33 23 35 32 33 28 32 30 32 27 31...
In a study of Marfan syndrome, Pyeritz et al.(A-34) reported the following severity scores of patients with no, mild, and marked dural ectasia. May we conclude, on the basis of these data, that mean severity scores differ among the three populations represented in the study? Let a ¼ :05 and find the p value. Use Tukey’s procedure to test for significant differences among individual pairs of sample means. No dural ectasia: 18, 18, 20, 21, 23, 23, 24, 26, 26,...
mips add matrix Can anyone help me with adding matrix in MIPS? This is the code given. We will be using it to run it in spim-cache Write an assembly code program to perform addition between two matrices A and B, and store the result into a matrix C, i.e, 1 2 3 4 51 [26 27 28 29 301 27 29 31 33 35 6 7 8 9 10 31 32 33 34 35 37 39 41 43 45...
The number of touchdowns of a college football team is: 38 36 23 33 37 36 35 34 43 27 36 38 21 26 26 27 33 22 28 36 Complete the frequency distribution. Class Interval Frequency Relative Frequency 21 - 24 25 - 28 5 0.250 29 - 32 33 - 36 37 - 40 3 0.150 41 - 44 1 0.050 Total 20 1.000
The data in ‘Problem 4’ show the top 30 home run totals in each League in Major League Baseball in 2018. Use Excel to perform the appropriate test to see if the American League’s top home run hitters had a higher average number of home runs than the top National League home run hitters did. Assume both data sets come from normally distributed populations. one tailed or two: Test statistic: p-value: decision: Did AL Average more HR than NL Did:...
These are my instructions: Your data should have been read in from the data file and stored into an array. Next you need to calculate the following and display in a single Message box: Average score Highest score Lowest score Mode of the scores Your program should be written using methods and should be well documented internally and externally. Your output should be displayed using Message boxes. This is the .text file to use with the instructions: 20 21 22...
Do the Academy Awards involve discrimination based on age? Listed below are the ages of actresses and actors at the times that they won Oscars in the Best Actress and Best Actor categories. the ages are listed in order, beginning with the first Academy Awards ceremony in 1928. (Note: in 1968 there was a tie in the Best Actress category, and the mean of the two ages is used; in 1932 there was a tie in the Best Actor category,...