Number of loops

The problem is from the website : http://uva.onlinejudge.org/external/118/11878.html

The code seems to work except that it loops 100 times but I am uncertain how many times it will loop in the checker. Is there any way to fulfill this statement in the problem:
" There will be at most 100 lines in the input. Each line contains a question with your younger brother's answer, formatted as stated above. There will be no space characters in each line (excluding the newline character). Numbers will never have leading zeros."


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  #include <iostream>
#include <string>
#include <cmath>
#include <cstring>

using namespace std;

int main (void)

{ 

int counter=0;


for (int m=0; m<=0101; m++)
{
	char x [100];
	cin >> x;
	double a= strlen(x)-1;
	int e= a-1;
	int num1=0, num2=0,num3=0, result, temp=0, temp2=0, temp3=0;
	int b,c,d;
	bool plus=false;
	bool minus=false;

	
	
	for (int n=0; n<a; n++ )
	{
		if (x[n] == '+') 
		{
			b=n;
			plus=true;

		}
		if (x[n] == '-') 
		{
			b=n;
			minus=true; 
		}
		if (x[n] == '=')
		{ 
			c=n;
			d= c-1;

		}
		if (x[n]=='?')
		{ 
			continue;
		}
	}
	
	
	for (int p=0; p<b; p++)
	{
		float h= b-p-1;
		float i =pow(10, h);
		temp= (x[p]-'0') * i ;
		num1+= temp+num1;
		
	}
	for (int q=b+1; q<c; q++)
	{
		float f= c-q-1;
		float j= pow(10, f);
		temp2= (x[q]-'0') * j;
		num2+= temp2+num2;

	}
	
	for (int r=c+1; r<a+1; r++)
	{
		float g= a-r;
		float k=  pow(10, g);
		temp3= (x[r]-'0') *k;
		num3+= temp3+ num3;
	}
	
	if (plus== true && num1 + num2 == num3)
	{
	
				counter= counter+1;
	}
	
	if (minus== true && num1-num2==num3)
	{
				counter= counter+1;

	}
	else 
	{
		counter = counter;
	}
}	
	cout << counter << "\n";

return 0;
	
	
}
	
	
Topic archived. No new replies allowed.