[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 599 KB, 890x800, 3d8e65e4b583c98e26a9a44323b77aff789da95d.png [View same] [iqdb] [saucenao] [google]
3857702 No.3857702 [Reply] [Original]

In C++ how do I check if an int has a certain number in it? For example, checking if a number like 49 has a 9 in it.

>> No.3857706

divisibility tables and modulus operator
do your own homework

>> No.3857710

Design a gui using Visual Basic. Zoom and enhance the int, and rotate it by 75 degree by Z-axis for maximum effect.

>> No.3857720 [DELETED] 

>>3857706
I know about that but it doesn't help for a number like 17 that isn't evenly divisible by 9 but has a 7 in it.

>> No.3857729

>>3857706
I know about that but it doesn't help for a number like 19 that isn't evenly divisible by 9 but has a 9 in it.

>> No.3857738

>>3857702
Run it through a bayesian filter.

>> No.3857742

convert to string
search

>> No.3857750

>>3857710
Fucking moron. You have to use the reflections before rotate 75 degree.

>> No.3857754

>Convert to string
>check each character
^_^

>> No.3857771

>>3857750
No, you need to print.line, then run a typographic analysis.

Also, make sure you check 180 degrees, otherwise you may confuse a 9 for a 6.

>> No.3857772
File: 8 KB, 374x328, pic-related.png [View same] [iqdb] [saucenao] [google]
3857772

>> No.3857838

Here (because why not. I'm bored)

bool numFound(int numToBeFound,int numString){
int magnitude=1;

if(numString/10==0){
if(numToBeFound==numString){
return true;
}else{
return false;
}
}

while((numString/magnitude)!=0){
if((((numString%(magnitude*10))-(numString%magnitude))/magnitude)==numToBeFound){
return true;
}

magnitude*=10;
}
return false
}

>> No.3857843

>>3857838
I haven't thrown that by a compiler, by the way, so I can't guarantee it works, but it should.

Let me know the results.

>> No.3858940

>>3857729
You misunderstand. You don't divide by 9, you divide by 10 (and look at the remainder).

If (x%10 == 9), then the last digit of the decimal representation is a 9. Similarly, if ((x/10)%10 == 9), then the next-to-last digit of the decimal representation is a 9.