#include <stdio.h>
int main()
{
int a,b,sum=0,k=0,k2=0;
while(scanf("%d %d",&a,&b)!=EOF)
{
sum=a/b;
if(sum==1){
printf("%d\n",sum);
}
else if(sum>=1){
k=(sum-1)*2;
printf("%d\n",k);
}
else if(sum<=1){
k2=(1/sum)+1;
printf("%d\n",k2);
}
else if(sum==0){
printf("%d\n",sum);
}
return 0;
}
}
#include
int main()
{
int a,b,sum=0,k=0,k2=0;
while(scanf("%d %d",&a,&b)!=EOF)
{
sum=a/b;
if(sum==1){
printf("%d\n",sum);
}
else if(sum>=1){
k=(sum-1)*2;
printf("%d\n",k);
}
else if(sum<=1){
k2=(1/sum)+1;
printf("%d\n",k2);
}
else if(sum==0){
printf("%d\n",sum);
}
return 0;
}
}
return 0 就結束了,當然只有一行
#include <stdio.h>
int main() {
int a, b, sum = 0, k = 0, k2 = 0;
while (scanf("%d %d", &a, &b) != EOF) {
sum = a / b;
if (sum == 1) {
printf("%d\n", sum);
} else if (sum >= 1) {
k = (sum - 1) * 2;
printf("%d\n", k);
} else if (sum <= 1) {
k2 = (1 / sum) + 1;
printf("%d\n", k2);
} else if (sum == 0) {
printf("%d\n", sum);
}
}
return 0;
}
#include
int main()
{
int a,b,sum=0,k=0,k2=0;
while(scanf("%d %d",&a,&b)!=EOF)
{
sum=a/b;
if(sum==1){
printf("%d\n",sum);
}
else if(sum>=1){
k=(sum-1)*2;
printf("%d\n",k);
}
else if(sum<=1){
k2=(1/sum)+1;
printf("%d\n",k2);
}
else if(sum==0){
printf("%d\n",sum);
}
return 0;
}
}
return 0 就結束了,當然只有一行
#include
int main() {
int a, b, sum = 0, k = 0, k2 = 0;
while (scanf("%d %d", &a, &b) != EOF) {
sum = a / b;
if (sum == 1) {
printf("%d\n", sum);
} else if (sum >= 1) {
k = (sum - 1) * 2;
printf("%d\n", k);
} else if (sum <= 1) {
k2 = (1 / sum) + 1;
printf("%d\n", k2);
} else if (sum == 0) {
printf("%d\n", sum);
}
}
return 0;
}
他說溢位或者除以0的錯誤!!
Floating point exception (core dumped)
請問怎麼解決感謝:)