Home > other >  How do you find e ban numbers in a list of strings and only print the non- e ban numbers? e ban numb
How do you find e ban numbers in a list of strings and only print the non- e ban numbers? e ban numb

Time:06-22

e ban numbers. If a number that contains an e when you read it, then that number will be banned. Write a C program that will ask for a series of number. Your program will only print the numbers that are not e ban numbers. Your input and output will be integers.

Input: 4 44 1001 164 29 Output:4 44

It's my first time encountering with e-ban numbers. What algorithm do we use to determine them?

CodePudding user response:

The question is unclear what is meant by "reading the number". If it means that

164

is

one six four

then the function strcspn can be used to check out the number as a string – whether it contains the "e-ban" digits 0, 1, 3, 5, 7, 8, 9.

CodePudding user response:

Turn the integer input, e.g.

  • 44 into string representation like "fourty-four"
  • 1001 into "one thousand and one"

There are question on StackOverflow on how to do that step.
Then use a string searching function to look for "e".

This is intentionally not giving the full solution in code, matching How do I ask and answer homework questions?

  •  Tags:  
  • c
  • Related