I want this in C programming i wrote it in C++: #include using namespace std; int main() {    int tc,m,n,ts=1;    string str;    cout<<"No of test cases :";    cin>>tc; // reading number of testcases    while(ts<=tc)    {        vector v1; // vector to store string        cin>>n>>m;        for(int i=0;i>str;            v1.push_back(str); // push_back into the vector        }        int count=0; // count of starts        for(int i=0;i #define MAX_M 100 #define MAX_N 100 typedef enum {     false = 0,     true  = 1, } bool;   char bitmap[MAX_M][MAX_N]; bool visited[MAX_M][MAX_N];   void floodFill(int x, int y, int m, int n) {     if (x < 0 || y < 0 || x >= m || y >= n)     {         return;     }     if(bitmap[x][y] != '-' )     {         return;     }     if(visited[x][y] == true)     {         return;     }     visited[x][y] = true;     floodFill(x+1, y, m, n);     floodFill(x-1, y, m, n);     floodFill(x, y-1, m, n);     floodFill(x, y+1, m, n);     return;     } int main() {     int ts=1,tc;     printf("No of test cases :\n");     scanf("%d",&tc);            while(ts<=tc)     {         int m,n;         scanf("%d %d", &m,&n);          for (int i=0; i < m; i++){             for (int j = 0; j < n; j++){                     visited[i][j] = false;             }         }                   for (int i =0; i < m; i++)         {             scanf("%s", bitmap[i]);         }         int star_count = 0;         for (int i =0; i < m; i++)         {             for (int j =0; j < n; j++)             {                 if(bitmap[i][j] == '-'  && visited[i][j] == false)                 {                     star_count++;                     floodFill(i, j , m , n);                 }             }         }                   printf("Case %d: %d\n",ts, star_count);         ts++;     }          return 0; }   CHECK WORK ON KATTIS COUNTING STARS PLEASE THIS IS LIKE THE FOURTH TIME I HAVE ASKED FOR THIS QUESTION TO BE ANSWERD CORRECTLY WITH WHAT I NEED PLEASE

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I want this in C programming i wrote it in C++:

#include <bits/stdc++.h>
using namespace std;
int main()
{
   int tc,m,n,ts=1;
   string str;
   cout<<"No of test cases :";
   cin>>tc; // reading number of testcases
   while(ts<=tc)
   {
       vector<string> v1; // vector to store string
       cin>>n>>m;
       for(int i=0;i<n;i++) // reading string from user
       {
           cin>>str;
           v1.push_back(str); // push_back into the vector
       }
       int count=0; // count of starts
       for(int i=0;i<n-1;i++) // iterate over each string
       {
           int t1=0,t2=0,j=0;
           while(j<m)
           {
               if(v1[i].at(j)=='-') // if - occur go until # found
               {
                   while(j!=m && v1[i].at(j)!='#')
                   {
                       if(v1[i+1].at(j)=='-') // if we have - at same position in next line don't count using t2
                       t2=1;
                       j=j+1;
                   }
                   if(t2==0) // if no such - at next level in same - occur at line
                   count=count+1; // increment count
                   t2=0;
               }
               else
               j=j+1;
           }
       }
       int t3=0;
       for(int j=0;j<m;j++)//iterate over last string
       {
           if(v1[n-1].at(j)=='-') // if - occur go until # found and count++
           {
               t3=1;
           }
           else if(t3==1)
           {
               count+=1;
               t3=0;
           }
       }
       cout<<"Case "<<ts<<":"<<count<<endl; // print result
       ts=ts+1;
   }
}

 

THIS IS THE POBLEM 

 you should write such an analysis program which counts the number of stars visible in an bitmap image. An image consists of pixels, and each pixel is either black or white (represented by the characters # and -, respectively). All black pixels are considered to be part of the sky, and each white pixel is considered to be part of a star. White pixels that are adjacent vertically or horizontally are part of the same star.

Input

Each test case begins with a line containing a pair of integers 1≤m, n≤100. This is followed by mm lines, each of which contains exactly nn pixels. Input contains at least one and at most 50 test cases, and input ends at the end of file.

Output

For each case, display the case number followed by the number of stars that are visible in the corresponding image. Follow the format of the sample output.

 

I got this one and it didnt work

 

#include <stdio.h>
#define MAX_M 100
#define MAX_N 100


typedef enum
{
    false = 0,
    true  = 1,
} bool;

 

char bitmap[MAX_M][MAX_N];
bool visited[MAX_M][MAX_N];

 

void floodFill(int x, int y, int m, int n)
{

    if (x < 0 || y < 0 || x >= m || y >= n)
    {
        return;
    }
    if(bitmap[x][y] != '-' )
    {
        return;
    }
    if(visited[x][y] == true)
    {
        return;
    }

    visited[x][y] = true;

    floodFill(x+1, y, m, n);
    floodFill(x-1, y, m, n);
    floodFill(x, y-1, m, n);
    floodFill(x, y+1, m, n);

    return;    
}


int main() {

    int ts=1,tc;
    printf("No of test cases :\n");
    scanf("%d",&tc);
      
    while(ts<=tc)
    {
        int m,n;
        scanf("%d %d", &m,&n); 
        for (int i=0; i < m; i++){
            for (int j = 0; j < n; j++){
                    visited[i][j] = false;
            }
        }
    
    
        for (int i =0; i < m; i++)
        {
            scanf("%s", bitmap[i]);
        }
        int star_count = 0;
        for (int i =0; i < m; i++)
        {
            for (int j =0; j < n; j++)
            {
                if(bitmap[i][j] == '-'  && visited[i][j] == false)
                {
                    star_count++;
                    floodFill(i, j , m , n);
                }
            }
        }
    
    
        printf("Case %d: %d\n",ts, star_count);
        ts++;
    }

    

    return 0;

}

 

CHECK WORK ON KATTIS COUNTING STARS PLEASE THIS IS LIKE THE FOURTH TIME I HAVE ASKED FOR THIS QUESTION TO BE ANSWERD CORRECTLY WITH WHAT I NEED PLEASE 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY