3 回答
TA贡献195条经验 获得超115个赞
有点看不清你的,按照你的源码编的,运行没问题啊:
#include <stdio.h>
int main(void) {
int x,y,i;
for(i=101;i<200;i++){
for(x=2,y=1;i>x;x++){
if(i%x==0){
y=0;
break;
}
}
if(y==1)
printf("%d is prime\n",i);
else
printf("%d is not prime\n",i);
}
printf("test");
return 0;
}
输出:
101 is prime
102 is not prime
103 is prime
104 is not prime
105 is not prime
106 is not prime
107 is prime
108 is not prime
109 is prime
110 is not prime
111 is not prime
112 is not prime
113 is prime
114 is not prime
115 is not prime
116 is not prime
117 is not prime
118 is not prime
119 is not prime
120 is not prime
121 is not prime
122 is not prime
123 is not prime
124 is not prime
125 is not prime
126 is not prime
127 is prime
128 is not prime
129 is not prime
130 is not prime
131 is prime
132 is not prime
133 is not prime
134 is not prime
135 is not prime
136 is not prime
137 is prime
138 is not prime
139 is prime
140 is not prime
141 is not prime
142 is not prime
143 is not prime
144 is not prime
145 is not prime
146 is not prime
147 is not prime
148 is not prime
149 is prime
150 is not prime
151 is prime
152 is not prime
153 is not prime
154 is not prime
155 is not prime
156 is not prime
157 is prime
158 is not prime
159 is not prime
160 is not prime
161 is not prime
162 is not prime
163 is prime
164 is not prime
165 is not prime
166 is not prime
167 is prime
168 is not prime
169 is not prime
170 is not prime
171 is not prime
172 is not prime
173 is prime
174 is not prime
175 is not prime
176 is not prime
177 is not prime
178 is not prime
179 is prime
180 is not prime
181 is prime
182 is not prime
183 is not prime
184 is not prime
185 is not prime
186 is not prime
187 is not prime
188 is not prime
189 is not prime
190 is not prime
191 is prime
192 is not prime
193 is prime
194 is not prime
195 is not prime
196 is not prime
197 is prime
198 is not prime
199 is prime
test
- 3 回答
- 0 关注
- 1715 浏览
添加回答
举报