0
Could i done it simplier?
Array problem "What s my discount": Solved it like this: #include <iostream> using namespace std; int main() { double items[] = {500, 12.4, 94, 45, 3, 81, 1000.9, 85, 90, 1, 35}; //your code goes here int discount; cin >> discount; for ( int x = 0; x < 11 ; x++ ){ items[x] = items[x] - items[x] * discount / 100; cout << items[x] << " "; } return 0; } Was there a way to write the: (items[x] = items[x] - items[x] * discount / 100; ) simplier?
4 odpowiedzi
+ 2
item[x] -= item[x] * discount / 100;
+ 2
You can go ahead and leave it as someone else may run into the same issue :)
+ 1
or even:
item[x] *= 1 - discount / 100;
0
Interesting way of doing it, thx guys, should i delete the post after i get it solved?