#include<stdio.h>
int cheng(int, int);
int main()
{
int a,b,n=0;
for(n=0;n>=0;n++)
{
printf("input two number:");
scanf("%d%d",&a,&b);
if(a!=0&&b!=0){
printf("result:%d\n",cheng(a,b));
}
else printf("totle times:%d\n",n);
}
return 0;
}
int cheng(int a,int b)
{
int c=0;
c=a*b;
return c;
}
----------------解决方案--------------------------------------------------------
OK了嘛.
----------------解决方案--------------------------------------------------------
你编的好像是个无限循环,没有END的
----------------解决方案--------------------------------------------------------
输出了TOTLE之后,居然还要循环下去...到那里就应该停了
----------------解决方案--------------------------------------------------------
试试我放在10楼的.看行不行,应该没什么问题,也调用了函数
我觉得没必要用for循环,当然,用for的话记得用break跳出,也是一样可以的
----------------解决方案--------------------------------------------------------
请问楼上的loop,,goto loop;是什么作用啊。 .我怎么从来没用过.
----------------解决方案--------------------------------------------------------
只要喜欢,总会学好的.现在好象不怎么用goto语句了,破坏程序的可读性了
----------------解决方案--------------------------------------------------------
我才学不久,也来做做
#include <stdio.h>
int main()
{
int a,b,i;
scanf("%d,%d",&a,&b);
for(i=0;a!=0 || b!=0;i++)
{
printf("result is %d.\n",a*b);
scanf("%d,%d",&a,&b);
}
printf("the time is %d.\n",i);
return 1;
}
----------------解决方案--------------------------------------------------------
说回来,goto语句还是少用的好。。。。。
----------------解决方案--------------------------------------------------------
void main()
{
prnt();
}
void prnt()
{
char ch;
int a,b,num=0;
for(;;)
{
printf("请输入两个数\n");
while(scanf("%d %d",&a,&b)==2)
{
if(a*b!=0)
{
printf("结果:%d\n",a*b);
num++;
}
else
{
printf("总计算次数:%d次\n",num);
}
}
while((ch=getchar())=='\n');
}
}
----------------解决方案--------------------------------------------------------