Click here to Skip to main content
15,890,512 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to double click desktop icon programatically? Pin
Graham Shanks15-Aug-09 23:04
Graham Shanks15-Aug-09 23:04 
QuestionHow to print an a 4x4 array in clockwise direction Pin
sharp_k15-Aug-09 8:59
sharp_k15-Aug-09 8:59 
AnswerRe: How to print an a 4x4 array in clockwise direction Pin
Chris Losinger15-Aug-09 9:36
professionalChris Losinger15-Aug-09 9:36 
AnswerRe: How to print an a 4x4 array in clockwise direction Pin
Moreno Airoldi15-Aug-09 9:59
Moreno Airoldi15-Aug-09 9:59 
GeneralRe: How to print an a 4x4 array in clockwise direction Pin
sharp_k15-Aug-09 21:14
sharp_k15-Aug-09 21:14 
GeneralRe: How to print an a 4x4 array in clockwise direction Pin
Moreno Airoldi15-Aug-09 22:54
Moreno Airoldi15-Aug-09 22:54 
GeneralRe: How to print an a 4x4 array in clockwise direction Pin
sharp_k16-Aug-09 4:59
sharp_k16-Aug-09 4:59 
GeneralRe: How to print an a 4x4 array in clockwise direction Pin
Moreno Airoldi16-Aug-09 7:50
Moreno Airoldi16-Aug-09 7:50 
No problem, here is the version with separated row and column indexes:

C
#include <stdio.h>

void PrintArrayClockwise(int array[][4], int rows, int columns)
{
	int r = 0;
	int rh = rows / 2;
	int i;
	while (r < rh)
	{
		for (i=r; i<(columns - r); i++) printf("%d ",array[r][i]);
		printf("\n");
		for (i=r+1; i<(rows-r); i++) printf("%d ",array[i][columns-r-1]);
		printf("\n");
		for (i=(columns-r-2); i>=r; i--) printf("%d ",array[rows-r-1][i]);
		printf("\n");
		for (i=rows-r-2; i>r; i--) printf("%d ",array[i][r]);
		printf("\n");
		r++;
	}
}

int main()
{
	int numbs[4][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};

	PrintArrayClockwise(numbs, 4, 4);

	return 0;
}


Unluckily there's no way of passing a bydimensional array to a function without indicating the second dimension, at least none that I know of (but my ansi C is VERY rusty hehe). It sure can be done with int** anyway. Smile | :)

2+2=5 for very large amounts of 2
(always loved that one hehe!)

GeneralRe: How to print an a 4x4 array in clockwise direction Pin
sharp_k16-Aug-09 8:50
sharp_k16-Aug-09 8:50 
GeneralRe: How to print an a 4x4 array in clockwise direction Pin
Moreno Airoldi16-Aug-09 9:35
Moreno Airoldi16-Aug-09 9:35 
GeneralRe: How to print an a 4x4 array in clockwise direction Pin
sharp_k16-Aug-09 13:58
sharp_k16-Aug-09 13:58 
QuestionVisual C++ 2008 runtime! Pin
Hadi Dayvary15-Aug-09 8:31
professionalHadi Dayvary15-Aug-09 8:31 
AnswerRe: Visual C++ 2008 runtime! Pin
Chris Losinger15-Aug-09 9:38
professionalChris Losinger15-Aug-09 9:38 
GeneralRe: Visual C++ 2008 runtime! Pin
Hadi Dayvary15-Aug-09 9:43
professionalHadi Dayvary15-Aug-09 9:43 
AnswerRe: Visual C++ 2008 runtime! Pin
Joe Woodbury15-Aug-09 10:51
professionalJoe Woodbury15-Aug-09 10:51 
GeneralRe: Visual C++ 2008 runtime! Pin
Hadi Dayvary15-Aug-09 19:33
professionalHadi Dayvary15-Aug-09 19:33 
AnswerRe: Visual C++ 2008 runtime! Pin
Stuart Dootson15-Aug-09 13:45
professionalStuart Dootson15-Aug-09 13:45 
QuestionWhat is the C++ syntax for c# "typeof(string)"? Pin
Member 391164315-Aug-09 6:50
Member 391164315-Aug-09 6:50 
AnswerRe: What is the C++ syntax for c# "typeof(string)"? Pin
Hristo-Bojilov15-Aug-09 7:16
Hristo-Bojilov15-Aug-09 7:16 
GeneralRe: What is the C++ syntax for c# "typeof(string)"? Pin
Member 391164315-Aug-09 8:06
Member 391164315-Aug-09 8:06 
QuestionHow to open network addaptor Status dialog programatically. Pin
birajendu15-Aug-09 3:48
birajendu15-Aug-09 3:48 
AnswerRe: How to open network addaptor Status dialog programatically. Pin
Hamid_RT15-Aug-09 21:22
Hamid_RT15-Aug-09 21:22 
AnswerRe: How to open network addaptor Status dialog programatically. Pin
kilt17-Aug-09 3:29
kilt17-Aug-09 3:29 
QuestionHow to add a new column of the open file dialog which in the detail mode? Pin
Member 600960315-Aug-09 3:32
Member 600960315-Aug-09 3:32 
QuestionI need a drag-drop contrl - vertically inside parent window Pin
includeh1015-Aug-09 3:12
includeh1015-Aug-09 3:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.