另外用while做
#include<stdio.h>
#include<conio.h>
int main(void)
{
int a,b,n=0;
while (1)
{
printf("input two number:");
scanf("%d %d",&a,&b);
if ((a!=0&&b!=0)||(a!=0||b!=0))
{
printf("%d\n",a*b);
n++;
}
else
{
printf("%d",n);
break;
}
}
getch();
return 0;
}
#include<conio.h>
int main(void)
{
int a,b,n=0;
while (1)
{
printf("input two number:");
scanf("%d %d",&a,&b);
if ((a!=0&&b!=0)||(a!=0||b!=0))
{
printf("%d\n",a*b);
n++;
}
else
{
printf("%d",n);
break;
}
}
getch();
return 0;
}
用for.if.break做的.
#include<stdio.h>
#include<conio.h>
int main(void)
{
int a=1,b=1,n;
for (n=0;(a!=0&&b!=0)||(a!=0||b!=0);n++)
{
printf("input two number:");
scanf("%d %d",&a,&b);
if(a==0&&b==0) break;
else
{
printf("%d\n",a*b);
continue;
}
}
printf("%d",n);
getch();
return 0;
}
#include<conio.h>
int main(void)
{
int a=1,b=1,n;
for (n=0;(a!=0&&b!=0)||(a!=0||b!=0);n++)
{
printf("input two number:");
scanf("%d %d",&a,&b);
if(a==0&&b==0) break;
else
{
printf("%d\n",a*b);
continue;
}
}
printf("%d",n);
getch();
return 0;
}
当是练习循环了...- -正好闲着没事.书看的眼疼.
[此贴子已经被作者于2007-9-13 17:40:47编辑过]