473,385 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Please help me with these problems.... [homework]

Hi everybody,
My name's Jack and I'm a newbie in this forum...
Nice to meet you all and i hope i can get along in this forum...
And I also hope that you can help me with my problem...
I'm a very beginner programmer that still learn in C language programming taht I hope I can be an advanced programmer or even expert programmer later :) I have a quiz from my author before and until now I still can't describe how to make this program...

These are the Quiz...

1. Make a program that ask an input from user.
The input is integer number with range 1 - 100
And show the output of the numbers in spiral (rouding) shape

Example:
Input : 9

Output :
5 4 3
6 1 2
7 8 9


Input : 13

Output :
13
5 4 3 12
6 1 2 11
7 8 9 10

2. Make a program that ask an input from user.
The input is an odd number (N)
And show the output in matrix shape from N to N*N
but the numbers must have a same value when it's sum
in horizontally, vertically, and diagonally.

Example:
Input : 3
Output :
8 1 6 = 15
3 5 7
4 9 2

ll
15


I hope i can get your reply soon...
Oh yeah these progrom should be in C language
Thanks before, guys...
Sep 9 '06 #1
3 2407
sorry guys for the bad view of output.
In question number 2
the 13 number on the output should be above the 12 number
I hope you can understand...
Sep 9 '06 #2
Niheel
2,460 Expert Mod 2GB
This is a homework assignment. You have to try it yourself first. When you get stuck, you can then paste your code and we can help debut.
Sep 11 '06 #3
D_C
293 100+
Hint for #1
Look where the perfect squares are located. The even ones line up on a diagonal, and the odd one line up on an adjacent diagonal. That way, you can estimate the size of a matrix needed for this calculation. The even and odds do not line up, you should take notice how this affects the starting position (where is 1 in relation to the dimension of the matrix).

Initialize all matrix values to zero. The outer loop should control the direction and conditionally increment the distance you traverse in the matrix, while the inner loop counts the distance travelled and also assigns matrix entries.

After you count all the way up to the number, traverse through the matrix by row, then by column. Print only initialized values, and blank spaces otherwise.

Hint for #2
Search this forum, someone was doing a similar problem not that long ago. "Magic Square" is how people usually refer to it.
Sep 11 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: slickn_sly | last post by:
How would i go about implementing a program in java that would do the following, f(1) = 1; f(2) = 1; f(3) = 1; f(4) = 1; f(5) = 1; f(n) = f( n - 1 ) + 3 * f( n - 5 ) for all n > 5 and...
3
by: Rv5 | last post by:
I have an assignment due mid next week that I have completed. I was hoping someone could take a look at the code and tell me what they think of the style. Id like to know if this is good code...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
4
by: n_ukharit | last post by:
i have an program but i don't know how to do it problem is enter a and z character and digits 0to9 using switch statement then display morsecode equivalent of character entered
2
by: Steven Chumney | last post by:
Exam week is here and we do not have our projects complete. If anyone is willing to help we would greatly appreciate it. These are probably simple for someone with experience, but we are completely...
6
by: darren112 | last post by:
Hi Im new to python and I desperately need help with this task.... This is everything of what I need to do....... The program to be written in Python obviously...... The program should support...
4
by: skatemore9690 | last post by:
#1 in Calculus you learned that log(1+x) = x - x^2/2 + x^3/3 - x^4/4 + ... for x in the interval (-1,1] (here x^2 means "x squared", etc.). Write a program which asks the user to type a...
4
by: Kausar.Nazir | last post by:
Pronlem# 1: How can I Create a notepad file named number.txt which consists of int type numbers separated with new lines on your hard disk, a program which read the numbers form this file and show...
62
by: vubaboota | last post by:
I HAVE SOME SERIOUS PROBLEM , HOW TO MAKE A PROGRAM IN C Q1: Write a program using malloc function. In which you take input from user and allocate memory equal to square of this number. Which...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.