Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!

Mark Spen

Ranch Hand
+ Follow
since Apr 29, 2020
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mark Spen

Hello Guys, i need your help if you can ofcource.I have made a carousel of images and i have captions in each image.I have done this using Bootstrap 4. Unfortunately,when i zoom my page with the carousel,my captions change position and some sentences do not appear beacause they do not fin in the carousel-image. Any idea how can fix this?

Thank you!
I work this exercise on C language,as well.
3 months ago

John Matthews wrote:Hi Mark

Do you know the range of the numbers? If you do, and it's 'small' eg. 0..9, then you can just use an array of counts which is indexed by number. You go through the array, and for each number N you increment count[N].

But if the range is 'big', or you don't know it, then it becomes a bit more complicated. I would probably use a list of number/count pairs, but there are various ways to implement a 'list'.

I'm assuming this is C - if it's C++ (not my strong point) then there are likely to be better options for the big/unknown range case based around hashing.

So, C or C++, and do you know the number range?

I don't know how much rows have each time.Only  i know  is that my columns are 7.I have thought to create a new array to store here the frequency but i don't know what to do when i found again the element that previously  have found their frequency.
3 months ago
Hello!I have an 2d array which have numbers and i want to find the frequency  of each number.Can you help or give me some advice to manage this??

Thank you!
3 months ago

John Matthews wrote:But if you do want to count the number of lines first, a simple way is to just read a character at a time using fgetc() until you hit EOF, incrementing your line count if the character is the end-of-line '\n' character. Then, after allocating you array, use rewind() to go back to the beginning of the file and read the numbers.

No i don't store dynamically the numbers in array.So i 'll try this solution with count the lines and when this end i'll call the rewind,right??
3 months ago
Hello guys!I want your help if you can.I want to read numbers from a file and store it in a 2d array.My problem is that i do not know how many lines has my file each time,each line has 7 numbers.I imagine that  i should find how many lines has my file while i read the file but i don't have any idea.Can you help me please??

Thank you!
3 months ago
Hello!I would like to answer something about strings.I have made a hashmap which the key is a char,especially a letter and the value is two integers.Each letter corresponds in two integers.For example h thas the key 99.I want to print each phrase i give as a stirng of integers.Especially for hello i want o print it like 9987656534. To return this string of integers i have done this:  String.valueOf(a1.values()); a1 is my hashmap but my result is [99,87,65,65,34].How can fix this?
Thank you!
5 months ago

Campbell Ritchie wrote:Please put code tags round your submitted code; it is very difficult to read as it is.
Why are you using floats for money? Why are you using floats at all? Any floating‑point arithmetic has too much imprecision to use for money, and floats are far worse than doubles.
Stop thinking in terms of a 0.01¢ coin; it is a 1¢ coin, and then do all your arithmetic in integers so €1 counts as 100.
Your arithmetic looks very complicated. You can calculate the number of 200 coins (=2€) simply by dividing the money by 200. Similarly you can calculate the remainder with the remainder operator %. It only works reliably in integer arithmetic, and your values shouldn't be negative, so use unsigned instead of int numbers. That means you can't calculate change < 0, but have to test whether you have enough money to buy the tickets first.

Ok thank you for you advice and i really appreciate it!!
6 months ago

Mike Simmons wrote:Sounds like you would need to show some code of exactly what you did.

My programm wants to buy tickets.The input is the amount of tickets i want and the money which i have.
Here is my code i have to return changes in 2,1 euros and 0.5,0.2,0.1,0.05,0.01 cents when someone wants to buy a ticket

#include <stdio.h>
#include <stdlib.h>
#define ticket 0.75
#include <math.h>
int main()

  int amount,piliko,piliko1,piliko2,piliko3,piliko4,piliko5,piliko6;
  float money,changes,ipoloipo,ipoloipo1,ipoloipo2,ipoloipo3,ipoloipo4,ipoloipo5;
  scanf("%d%f",&amount,&money); //amount is the number of tickets
  if((amount>=1 && amount<=5) && (money>=0.75 && money<=100))
           printf("Wrong input");
           return 0;








       printf("%d * 2 euros\n",piliko);
       printf("%d * 1 euros\n",piliko1);
       printf("%d * 50 cents\n",piliko2);
       printf("%d * 20 cents\n",piliko3);
       printf("%d * 10 cents\n",piliko4);
       printf("%d * 5 cents\n",piliko5);
      printf("%d * 1 cents\n",piliko6);


     printf("Wrong input");
   return 0;
My problem is when i want 1 ticket and my money is 8.9 my output is 4*2 euros,1*10 cents, 4*1 cents and the correct answer is 4*2 euros,1*10 cents,1*0.5 cents.Something wrong happen when i divide ipoloipo4 with 0.05
6 months ago
Hey guys!I have a question about the division between two float numbers.My result from a devision is 0.05 and when i divided with 0.05 the result is 0 and i expected to be 1.What happened exaclty??
6 months ago
Hello everyone!I am trying to do a programm in java using arraylist!I have made two classes Movie and Actor.My problem is that i want to use some methods to Actor class from Movie class and i do not know how to do this.Can you help me please.Help me if you can and give me your advices!!
Here is my two classes.

7 months ago
Hello everyone!I have made a programm who has two functions!My 1st function calculating the character which appear most times and the character which appear less times.My 2nd reverse a string.My problem is when i upload my programm in a platform to pass some test,my programm does not run and the platform print invalid memory reference.Have you got any idea what happend exactly?Thank you!!
here is my code

8 months ago

Campbell Ritchie wrote:Please format your code correctly. Spaces around operators please, and declarations on their own line please. Line 4 is illegible, and the variable names are difficult to follow.
Please explain what you want to happen and what does happen, with examples to make the problem clear. Put some debugging instructions in, printing the value of the char and showing progress of the copying.
Please also put some instructions for the user; who knows what they are supposed to write?

You are right!My programm wants to give you a string ,a char and delete this char from the string.For example the string hello and the char l, my output want to be heo.Unfortunately my output is something like  this &*%$.
In line 4 made the variable n1 to find the length of my string,n2 is a counter to find how many times my char is in my string.n3 is the difference between n1 and n2 and i use it to find how many characters my string will have.
In my second loop i try to find which characters are different from the character i gave and store it in my new string.I hope understand my explanation.
9 months ago
Hey!I need your help again if you can!I made a function who wants to copy a string without a character! I made my function but my output is a string of symbols not a string of letters!Can you take a look in my code to find if i have a mistake?Thank you!
Here my code.
9 months ago
Thank you for your help!I fixed my programm with the things that you said me!It works!!Really thank you!!
9 months ago