#include “stdafx.h”
int add(int a,int b)
{
int answer;
printf(“两数之和为:”);
scanf_s("%d",&answer);
if(a+b==answer)
return 1;
else
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
int a,b,i,c,n=3;
printf(“请输入两个加数,中间用+连接:”);
scanf_s("%d+%d",&a,&b);
c=add(a,b);
for(i=1;i<=n;i++)
{
if(c==1)
{
printf(“Right!\n”);
break;
}
else
{
switch(i)
{
case 3:printf(“Not correct. You have tried three times! Test over!\n”);break;
default:printf(“Not correct! Try again!\n”);
}
c=add(a,b);
}
}
}