I need help setting up a function that inputs a ppm file and flips it horizontally in the output in C++ using a 1D vector
#include <stdio.h>
#include <stdlib.h>
//i have taken a 1D array as input. All you need to do here is
take the ppm file and find its height and width, The function to
flip horizontally will remain the same.
//So basically here we are taking a single dimensional array.
/*1 2 3 4
5 6 7 8
9 10 11 12 */
//consider this as an input.
void fliphorizontally(int a[],int width,int height)
{
int i=0;
while(i<height) //we will run the code depending on
the height.
{
int length=((2*i+1)*width)/2;
//This takes the middle of each row. According to the height and
then flip it.
int count=0; //We have this to make
sure where the count is at present.
for(int
j=i*width;j<length;j++)
{
int
temp=a[j];
a[j]=a[width*(i+1)-1-count]; //We use it to flip each row.
a[width*(i+1)-1-count]=temp;
count++;
}
i++;
}
}
int main()
{
int n=12,width=4,height=3; //Just for your reference i
have inputted a width and a height of the ppm file.
int a[]={1,2,3,4,5,6,7,8,9,10,11,12}; //i have taken
an input of pixels for u to understand.
fliphorizontally(a,width,height);
for(int i=0;i<n;i++) //I have inputted the file
after flipping.
{
printf("%d ",a[i]);
}
}
//Hope i could be of help
I need help setting up a function that inputs a ppm file and flips it horizontally...
Hello! I need help setting my program up to initiate certain tasks! We are using a Centos Server as a root user! Use the CentOS Server and as root user perform the following: Setup two ext4 partitions on /dev/sdc at 1 GB each Mount sdc1 to /var/www (create any directories as needed) Mount sdc2 to /var/data (create any directories as needed) Install the httpd package Create a file called final.txt in /var/www/html (in that put your name/date on the first...
I just need help setting this up. Ive tried two different ways
and neither of them is getting me the right answer.
For the function: f(x) 2x2 + 1, find f(x) f(a) a. 2x+2a revieW T-a f(z +h) -f(z) 蠶 Preview ea syntax error Post this question to forum
PLEASE HELP, MATLAB, answers are very appreciated need to
study
pl
2. Write two m-file functions that will allow you to compare mortgages cakculations for the monthly payment and compare mortgage with different loan values. The monthly payment M, is calculated using 1-2)1 Where Pis the principal loan amount, r is the interest rate (in decimal form not percent form), and y is the number of years of the loan. Create an m-file function called "mortgage_a.m" that will serve as...
I need help with a c++ function. I need this function to read in an input file containing multiple choice questions/potential answers and to store that data into a 2d array of strings. This function cannot use classes or vectors or anything "advanced". The input file will have 0-50 questions; each with 4 multiple choice responses. The array should be titled questionArray. (it's a .txt file) update: What is my name? John Bob Lance Mike What is my favorite animal?...
C++ need help with vector. I have a text file and input it's content into a struct that holds an array for each entry as a string type. for example: struct container{ string ID[10000]; string anotherID[10000]; } in the text file there is a huge list that looks something like this: 1 abc 3 xyz 1 abc 1 xyz How can I use a vector to sort these so I can get an output like ID: 1 and anotherID: abc...
Please use excel, need help with functions and setting up cash flows in Excel because I am only used to using a financial calculator, thanks! You are offered an asset costing $900 that has cash flows of $200 at the end of each of the next 10 years. If the appropriate discount rate for the asset is 12%, should you purchase it based on its NPV? What is the IRR of the asset?
I mostly need help setting up what two equations I need to use A liquid feed stream (F, 200 kg/h) mixture containing 25% benzene and 75% toluene by weight enters a distillation column. The column produces two product streams (D and B). The product leaving the top of the column (D) is 98% benzene by weight, and contains 95% of all the benzene leaving the system. Write a system of two linear algebraic equations to solve for the mass flow...
I need help setting up this problem and identifying the variables Energy change is the sum of heat and work: ΔE = q + w. Work is calculated by: w = -PΔV What is the change in energy (in joules) if a reaction loses 215 J of heat and decreases in volume from 0.650 L to 0.225 L at a constant pressure of 3.17 atm? Please include the correct sign with your numerical result.
C hash function i need a hash function that takes string inputs of "L1-0007835" and computes a number with low collisions
In C: I need help up implementing this function that takes a line and breaks it into words without using sscanf /* This function takes a line and breaks it into words. The orginal line is in the char array str, the first word will go into the char array c, the second into p1, and the the third into p2. If there are no words, the corresponding char arrays are empty. At the end, n contains the number of...