C :: Make Rotation To 2d Array Without Using Any Other Array

Dec 7, 2014

which asking to make a rotation to a 2d array without using any other array , so here's an example :

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

i want to add 90 degree so :

13 9 5 1
14 10 6 2
15 11 7 3
16 12 8 4

View 2 Replies


ADVERTISEMENT

C++ :: Array Char Rotation And Arrow Key Usage

Apr 27, 2013

I am doing a project for a class which involves making a game where there is an arrray that holds a player (you) and a zombie (comp). The player is suppose to be able to turn clockwise or counter clockwise, move forward, and backward and shoot. Im having trouble trying to rotate the char in an array. I am also trying to switch from using the W,S,D,A to the arrow keys but doesnt seem to work.

#include <iostream>
#include <windows.h>
#include "color.h"
using namespace std;
using namespace Petter;
const int COL = 15;
void initBoard(char[][COL], int, int);

[Code] ....

View 5 Replies View Related

C :: How To Make A Function Read From Array A But Put Select Parts In Array B

Jul 30, 2013

im trying to read in 1 array and get 2 as outputs from 3 different functions.my read array is easy enough were im getting confused is how to read that array, separate it and take out only the parts i want and place them into a 2nd, then again a 3rd array.i have the following so far:

Code:

#include<stdlib.h>#include<stdio.h>
#include<unistd.h>
#define SIZE 10
}

[code]....

this compiles without a complaint, but when i go to run it no longer responds after taking the 10th element (well 9th if counting from 0).I think i have the if correct for the even odd section, but when i try to populate B or C array with the output of that if statement from A is were i think things are dying...

View 12 Replies View Related

C++ :: How To Make 2 Array (x / Y) String

Jun 9, 2013

I want to make 2 array(x,y) string , when i do

string temp[8][8]

but

cout << temp[3][4] does not work ....

View 3 Replies View Related

C++ :: Make Class For 2D Array

Mar 20, 2014

I want to make Class for 2D array.

This is part of Class Definition.

class CMatrix{
public:
explicit CMatrix( int rows, int cols ){
m_pArray = new float[ rows * cols ];
m_nRows = rows;

[Code].....

View 6 Replies View Related

C++ :: Copy To Make 1D Array A 3D Matrix

Jun 3, 2013

I'm trying to copy my array 'block' to a 'dummy' 3D matrix so I can take out some arbitrary smaller matrix. Shouldn't this be possible with std::copy, where I'm certain the number of elements in the 1D array are equivalent to those in the dummy?

int dummy[210][210][1000];
std::copy(&block[0], &block[block.size()], &dummy);

View 2 Replies View Related

C++ :: How To Make Array Of Objects For Class

Aug 18, 2013

class A {
Public:
A (int);
A(int,int);
int get (int,int);
};

View 5 Replies View Related

C++ :: How To Make Array With A Range Of Numbers From 1 - 9 Only

Jan 29, 2013

I want to make an array with a range of number from 1-9 only. So if the user entered more than or less than the number indicated it will be error and ask the user to reinput the data. So far my code can be used to do so that if the user enter the number one by one... But if the user entered all the number in one shot the reentered value will be prompt to the back automatically for some reason...Let say 10,2,3,4 which was suppose to be 1,2,3,4 became 2,3,4,1 instead... here is the code:

#include<stdio.h>
void main() {
int num[4][4];
int row,col,x,y;
for(row=0;row<4;row++)

[Code] .....

View 3 Replies View Related

C :: Make Array Which Contains Arrays But With A Variable Size

Jan 29, 2015

I am wondering how I could make an array which contains arrays, but with a variable size.My first try..

Code:

int array[][] = {{1}, {2}};

But this isn't proper

View 2 Replies View Related

C++ :: How To Make Array Which Stores Values From User

Sep 22, 2013

How to make an array which stores the values i'm getting from the users?

For example if i have a function which allows the user to give me values, how can i store them in an array.

View 4 Replies View Related

C++ :: Make A Function That Checks If Array Is A Permutation

Feb 16, 2014

I need to create a function with the following prototype:

bool isPermutation( const unsigned a[], unsigned elements );

unsigned a[] = {3, 0, 2, 1};
bool P1 = isPermutation( a, 4 );
would set P1 to true because the set of subscripts is {0, 1, 2, 3}, and the values are just a reordering of those values. On the other hand,

unsigned a[] = {3, 0, 2, 3};
bool P2 = isPermutation( a, 4 );
would set P2 to false because the set of subscripts is {0, 1, 2, 3}, but there’s no value that’s equal to 1.

I'm not exactly sure how to do this. I thought about it a couple different ways. I first thought about taking the range (max/min) and then checking to see if the numbers in between are equal from each other, distance-wise.

I then thought that I should just make this basically a sort function (I used bubble-sort), and then to just check if the numbers are equi-distant from each other.

This is my basic bubble-sort. Perhaps it is wrong, but I'm not certain...Perhaps I am making this function harder than it has to be.

unsigned temp = 0;
for (unsigned i = 0; i < elements; i++){
for (unsigned k = 0; k < elements-1; k++){
if (a[k] > a[k+1]){
temp = a[k+1];
a[k+1] = a[k];
a[k] = temp;
}}}

Should I do a sort like this, and then do something where I subtract a[i+1] - a[i], and see if that equals '1'?. I would think that would mean they would have to be equidistant. Even if this is correct, I feel like it could be more efficient.

View 4 Replies View Related

C/C++ :: How To Make Two Dimensional Dynamically Allocated Array

Dec 4, 2014

My output becomes nonsense when I changed i value. how can I make tyy[i] value depends both i(depends on cins value) and j(depends on saft.size())

for ( int i = 0 ; i < cins ; i++ ){
for (int j=1 ; j < saft.size() ; j++) {
if (ustk[i] > saft[j] && saft[j-1] > ustk[i]){
tyy[j] = ((ustk[i] - saft[j])*yy[i]);

[code] ....

View 6 Replies View Related

Visual C++ :: How To Make Random Array To Not Repeat

Feb 17, 2013

Here is my code for a simple game. paste it and try it.

#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;
int main (void) {
stringg[4],

[code]...

What they do (enter 4 actions)?

";
for (int ai = 0; ai < 4; ai++)
getline(cin, a[ai]);
cout << "

Where is happening (enter 4 locations)?

";
for (int li = 0; li < 4; li++)
getline(cin, l[li]);
for (int c = 0; c < 4; c++)
cout << g[rand() % 4] << " and " << b[rand() % 4] << " are " << a[rand() % 4] << " from a " << l[rand() % 4] << endl;
return (0);
}

At the end in the 4 lines some of the names, actions and locations repeat. How do I make them to not repeat and use every name that you will enter? do I need random_shuffle? How can I integrate it in my code?

View 1 Replies View Related

C :: How To Make String Array From Strings In Text File

Mar 24, 2013

I want to make a string array from strings in a text file. Itry to do this but i couldn't do, where is my mistake?

Code:

#include <stdio.h>
#include <stdlib.h>
int main(){
char cumle[100],*c,*dene[50];
FILE *input;
input=fopen("input.txt","r");

[Code]...

View 1 Replies View Related

C :: How To Make Array Of Structures For Basic Contact List In A Phone

Oct 17, 2013

So for class I have to make an array of structures for a basic contact list in a phone.

I understand the bones of the program and how to go about doing most of it but as far as arrays of structures go I am blind.
Code:

struct phone
{
char FirstName[16];
char LastName[16];
int Number[11];
};
struct phone numbers[friends]; //friends is a variable assigned by the user What I am a bit confused about is say the user enters 30 as how many friends they have. How would I assign a value to the 3rd struct for LastName?

View 3 Replies View Related

C :: Make Array Stop Reading From Input When It Hits A New Line?

Nov 25, 2013

I want the numbers to be put into the array until it hits a new line. Maximum number of numbers is 1000. What can I replace that while loop with to stop it from reading further into the input file?

Code:

while (input != '
'){
for(i=0; i<1000; i++)
fscanf(ifp, "%lf", &auctions_prices[i]);

View 2 Replies View Related

C++ :: Read Data From File Then Make It Into Array Of Structures And Print Afterwards

May 13, 2012

I am trying to read from a data file that has input as :

12.0, 11, 123
14.0, 12.1, 3

And I want the program to read the data from the file and then make it into an array of structures and then print that array afterwards.

Code:
#include <stdio.h>
#include <stdlib.h>
#define MAX_INPUT 1000
int n =0;
int i = 0;
typedef struct {
double x[MAX_INPUT];

[Code] .....

The program when run gives the following output:

Ishtiaque-Mohammed-Khans-MacBook-Pro:Comp20005 IshtiaqueMKhan$ gcc -Wall -ansi -o ProjectB ProjectB.c
ProjectB.c: In function "main":
ProjectB.c:59: error: incompatible type for argument 1 of "print_array"

View 1 Replies View Related

C :: Make A Hash Table Array Of Linked Lists / Separate Chaining Technique

Jul 5, 2013

how to create a hash table array and use linked lists inside the elements.

View 5 Replies View Related

C :: AVL Left And Right Rotation

Feb 7, 2013

I am creating and implementing a left and a right rotation to balance a bst into an avl tree. I have made and tried 5 different codes that are commented in the functions left_rotate() and right_rotate() but none have run correctly. Sometimes the program works, sometimes there is a segmentation fault and sometimes not all inserted numbers are shown.

avl.c

Code:
#include<stdio.h>#include<stdlib.h>
#include<time.h>
#include "avl.h"
#define N 10
void swap(int *a, int *b){

[Code] ....

View 1 Replies View Related

C :: Image Rotation Without Cropping

Nov 4, 2014

I am new to image processing..... and I am learning the concepts.

Recently I have done image rotation of grey scale image using the following formula:

x' = xcos(theta)-ysin(theta)
y' = xsin(theta)+ycos(theta)

The problem i have faced is image is getting cropped.

I want to rotate an image without cropping. I have searched a lot but I am not getting any algorithm based on C. How to get the algorithm for image rotation without cropping.

View 2 Replies View Related

C++ :: Visualizing 3D Rotation Using Quaternion Data

Jun 10, 2014

Just bought a new ST Micro iNEMO-M1 system, and am looking to have my code visually show me the rotation information. I've got a working C++ code which actively acquires data from the sensor, and I'm looking to extend that into some visual interface which will show me on-screen the position of the sensor.

I figure using rotation information in the form of quaternion data is the most useful (want to avoid the gimbal lock problems associated with Roll/Pitch/Yaw).

What would be the best method to visualize the rotation of my sensor in real-time?

View 2 Replies View Related

C# :: Vertice Location After Quaternion Rotation

Aug 16, 2012

I have a 3d Point in space. From this point I have vertices defind by(scale). I have a Quaternion representing the rotation of the object (lets say a block). So...

(1) I know the point in local and world space and can translate.

(2) I know the scale of the object and it's starting vertices intersections at zero rotation.

(3) I have the quaternion which represents the 3d rotation and can translate that to degrees and Eulers.

How do i find the exact points of the vertices after the rotation. (what I'm attempting to do is plot points from vertice to vertice all along the sides/top/bottom of the object.)I have looked at Matrix4 transformations and Quaternions and still do not understand how to find the vertices after rotation.

View 8 Replies View Related

C++ :: How To Move Sprite Depending On Rotation

Jan 13, 2015

how I want my sprite movement to work: if my sprite is faced upwards and i press W, it will move up. If my sprite is faced to the right and i press W, it will go right. etc. // It doesn't work like that right now and how to do it.The sprite's rotation works fine.

if(sf::Keyboard::isKeyPressed(sf::Keyboard::Q)) {
playerSprite.rotate(-0.08 * dt);
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::E)) {
playerSprite.rotate(0.08 * dt);

[code]....

My question is how do I move the character depending on the rotation?

Also, you might see the "if(havePlayersCollided == false) {playerSprite.move(yadiyada)}" . yes i dont need the haveplayerscollided function because it doesnt work the way I want it to. I might make a thread for it in the future, but right now I need to get the rotation movement fixed before I move onto the collision detection between players.

View 7 Replies View Related

C++ :: Getting A Point Rotation Or Normal From 4 Vectors?

Dec 31, 2014

I'm trying to get a rotation of a spefic point in a 3D space using 3 or 4 coordinate/vector.

For example, I want to know the rotation of (5,5,5)

Using 4 vectors for example (0,0,0), (10,10,10), or 10,0,10, etc. (3 minimum)

View 2 Replies View Related

C++ :: Finding Rotation Direction From Two Orientations?

Mar 4, 2014

It is technically not a programming question and is more maths oriented. It has to do with game AI and specifically getting the AI to rotate correctly. I am trying to create the base method that handles AI rotation. It will take a target orientation and rotate the entity from it's current orientation to that target orientation.

Let's say we have a Entity that has the orientation of 1.57079 Radians (90 Degrees) and we want to change that Entity's orientation to 0 Radians (0 Degrees). How would one find the correct way to rotate from just them two orientations (IE find the shortest rotation direction from a current orientation to a target orientation)?

As my implementation stands now the Entity rotates just fine I think but always in a clockwise rotation (Because I can't figure out how to determine the best rotation direction). For example using the previous number (1.57079 Radians to 0 Radians) the Entity will rotate all the way around 270 Degrees clockwise instead of rotating just 90 degrees counter-clockwise.

I have thought about possibly projecting vectors a short distance forward from the current orientation and target orientation to figure out the rotation direction but not sure if that is a good way to implement it.

View 1 Replies View Related

C# :: Image Rotation Leaves Null Areas

Jan 29, 2015

I am working on a Paint program and I have a nice routine (copied from the Net) that beautifully rotates my Image by any chosen degree, and even preserving the entire Image with a 'noclipping' option.

The problem is - That after the rotation, say 45degrees, the areas in the corners, that originally were not part of the Image, cannot be drawn to. I have an 'eye dropper tool' that shows these areas to be null, having no color. My drawing tools will not work on these areas.

public static Bitmap RotateImage(Image image, float rotateAtX, float rotateAtY, float angle, bool bNoClip) {
int W, H, X, Y;
if (bNoClip) // use Clipping {
double dW = (double)image.Width;
double dH = (double)image.Height;
double degrees = Math.Abs(angle);

[Code] ....

View 13 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved