TEST: getting wa

Here is my code, I submit it as C++ gcc 4.3.2 :

#include <stdio.h>

using namespace std;

 void life (const int g, int* x)
    {
     
     
     for(int i=0; i<g; i++)
     {
         
         if(x[i]==42)
         {
             break;
         }
              
         printf("%d",x[i]);
         
         printf("\n");
        
     }
 }
 
int main(int argc, char** argv) {
    

    printf("Enter the number of inputs: ");
    
    int num;
    
    scanf("%d",&num);
    
   const int inputNumber = num;
    
     int* x;
     x = new int [inputNumber];
     
     printf("Enter each number, followed by Enter");
     printf("\n");
    
    for (int j=0; j<inputNumber; j++)
    {
       
        scanf("%d",&x[j]);
        printf("\n");
      
    }
   
    
    life(inputNumber, x);
    
    return 0;
}

Eu nĂŁo entendo qual Ă© o problema desse sistema aqui executou corretamente.

#include <stdio.h>

main() 
{
    int n;
    printf ("Insira um numero:");
    scanf ("%d", &n);
    while (n != 42 && n < 100)
    {
        printf ("%d\n", n);
        printf ("Insira um numero:");
        scanf ("%d", &n);	    
    }
}

in english please.

1 Like

your submission is incorrect as it prints strings that are not in the problem statement, such as :

  • "Enter the number of inputs: "
  • “Enter each number, followed by Enter”
1 Like

Yes, your output will be “Enter the number of inputs” and strings like that, you should only output numbers, and why do you store all numbers in array?
You should just read, check what do you have, and print a number.
:slight_smile:

first of all - missing return 0 statement and also read FAQ