Question

In: Computer Science

C Programming Language Title : Making wave In Physics, Mathematics, and related fields, a wave is...

C Programming Language

Title : Making wave

In Physics, Mathematics, and related fields, a wave is a disturbance of one of more fields such that the field values oscillate repeatedly about a stable equilibrium value. Waves are usually represented using mathematical functions of the form F (x, t), where x = position and t = time. Your task is to write a program that will visualize a given wave for exactly N seconds. You do not need to worry about evaluating the mathematical function F (x, t), as the wave will be given to you using its sample representation. The sample representation of a wave is a series of points that represents the result of the F(x, t) function at each given t. In this problem, you will be given N samples (one for each second) represented by N integers Yi , which represents the vertical coordinate of the wave at time i

Format Input

The first line contains a single integer N, the number of seconds you need to visualize the wave for. The next line contains N integers Y1,Y2,…,Yn as described in the problem statement.

Format Output

Visualize the wave given in the input. The wave should be visualized using a rectangle N characters long and 9 characters tall. Coordinates where the wave is currently in should be represented using the # (hash) character whilst empty coordinates should be represented using the . (dot) character. For clarity, please refer to the sample output section.

Constraints

• 1 ≤ N ≤ 10^4

• 1 ≤ Yi ≤ 9

Sample Input 1 (standard input)

9

1 2 3 4 5 6 7 8 9

Sample output 1 (standard output)

. . . . . . . .#

. . . . . . . # .

. . . . . . # . .

. . . . . # . . .

. . . . # . . . .

. . . # . . . . .

. . # . . . . . .

. # . . . . . . .

# . . . . . . . .

Solutions

Expert Solution

I have implemented the Program to print the Wave  per the given description.

Please find the following Code Screenshot, Output, and Code.

ANY CLARIFICATIONS REQUIRED LEAVE A COMMENT

1.CODE SCREENSHOT :

2.OUTPUT :

3.CODE :

#include <stdio.h>
#include <stdlib.h>
int main(){
        int n,i,j,t,k;
        //to read the value of 'N'
        printf("Enter N : ");
        scanf("%d",&n);
        //create a dynamic array of char
        char *arr[n],ch; 
    for (i=0; i<n; i++) 
         arr[i]=(char*)malloc(n*sizeof(char));
         //Initlize the array with .
        for(i=0;i<n;i++)
                for(j=0;j<n;j++)
                        arr[i][j]='.';
        //read the coordinate position
        printf("Enter %d Cordinate position : ",n);
        
        for(i=0,k=n;i<n;i++)
        {
                scanf("%d%c",&t,&ch);
                //Place the '#' sign at the position
                arr[k-t][i]='#';

        }
        //print the wave from the array
        printf("The Wave is : \n");
        for(i=0;i<n;i++){
                for(j=0;j<n;j++)
                {
                        printf(" %c",arr[i][j]);
                }
                printf("\n");
        }
}

Related Solutions

In Physics, Mathematics, and related fields, a wave is a disturbance of one of more fields...
In Physics, Mathematics, and related fields, a wave is a disturbance of one of more fields such that the field values oscillate repeatedly about a stable equilibrium value. Waves are usually represented using mathematical functions of the form F (x, t), where x = position and t = time. Your task is to write a program that will visualize a given wave for exactly N seconds. You do not need to worry about evaluating the mathematical function F(x,t), as the...
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing...
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing chess himself to practice his abilities. The chess that Jojo played was N × N. When Jojo was practicing, Jojo suddenly saw a position on his chessboard that was so interesting that Jojo tried to put the pieces of Rook, Bishop and Knight in that position. Every time he put a piece, Jojo counts how many other pieces on the chessboard can be captured...
C PROGRAMMING LANGUAGE PROBLEM TITLE : ARRAY usually, if people want to input number into an...
C PROGRAMMING LANGUAGE PROBLEM TITLE : ARRAY usually, if people want to input number into an array, they will put it from index 0 until N - 1 using for. But, Bibi is bored to code like that. So, she didin't want to input the number that way. So Bibi challenged you to make a program that will read a sequence (represent index) that she made, then input the number to an array but input it with the same sequence...
Programming Language: C# Person Class Fields - password : string Properties + «C# property, setter private»...
Programming Language: C# Person Class Fields - password : string Properties + «C# property, setter private» IsAuthenticated : bool + «C# property, setter absent» SIN : string + «C# property, setter absent» Name : string Methods + «Constructor» Person(name : string, sin : string) + Login(password : string) : void + Logout() : void + ToString() : string Transaction Class Properties + «C# property, setter absent » AccountNumber : string + «C# property, setter absent» Amount : double + «C#...
In the C programming language: Pretend you are an astrophysicist making a report on the distances...
In the C programming language: Pretend you are an astrophysicist making a report on the distances to the 50 brightest stars. You need to print out a nice table sorted by distance to include in your report. Using data in input.txt, write a program that can read in the included file input.txt. Use scanf or fscanf (or any other function you prefer) to read the comma separated values (CSV) into an array of structs representing each record. Once all records...
C Programming Language Problem Title : Take Three Jojo just graduated and moved up to grade...
C Programming Language Problem Title : Take Three Jojo just graduated and moved up to grade 4. Today is his first day in 4th grade. Unfortunately, the lessons are held online because of the pandemic. So that the quality of learning remains good, Jojo's teacher gives a hard task for 4th grader. After the 4th graders finished their first task which is prime factorization. Jojo's teacher set up a game for the stundets. The game is very simple. Given N...
C Programming Language Problem Title : 4th Grade Jojo just graduated and moved up to grade...
C Programming Language Problem Title : 4th Grade Jojo just graduated and moved up to grade 4. Today is his first day in 4th grade. Unfortunately, the lessons are held online because of pandemic. So that the quality of learning remains good, Jojo’s teacher gives a hard task for 4th grader. The first task is to find the prime factorization of a number. Prime number is a natural number greater than 1 that is not a product of two smaller...
C PROGRAMMING LANGUAGE Problem title : Bibi's Array Bibi also has an array containing N elements....
C PROGRAMMING LANGUAGE Problem title : Bibi's Array Bibi also has an array containing N elements. Like Lili, Bibi wants to know the highest frequency (most occurrences) and all elements which have that frequency. Format Input The first line contains an integer T stating the number of test cases. For each test case, the first line contains a single integer N which indicate the number of element in the array. The next line contains N integers Xi (1≤ i ≤...
C Programming Language Problem Title : Museum Heist Jojo loves art. In his free time, he...
C Programming Language Problem Title : Museum Heist Jojo loves art. In his free time, he usually goes to the museum and admires the artwork there. since Jojo loves are so much, he is planning a heist at the museum. Jojo knows the price of every piece of art and doesn't want to raise suspicion, so he decided to steal the second most expensive art piece. It is guaranteed that there are at least two art pieces with different prices....
GPA calculator in C language To understand the value of records in a programming language, write...
GPA calculator in C language To understand the value of records in a programming language, write a small program in a C-based language that uses an array of structs that store student information, including name, age, GPA as a float, and grade level as a string (e.g., “freshmen,” etc.). Note:Code and Output Screenshots
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT