0
C 프로그램이있어서 테스트 데이터가 들어있는 파일을 사용하여 테스트하고 결과를 자동으로 출력해야합니다. 어떻게해야합니까? 프로그램을 수정해야합니까? 아니면 C 나 Python과 같은 다른 프로그램을 써야합니까? 어느 것이 더 쉬울까요? 주위에 떠있는이 순간 무시하세요 이러한 리터럴C 프로그램에서 파일을 자동 테스트하는 방법은 무엇입니까?
int main()
{
double wh,sh,salary;
int num = 0;
int valid = 1;
printf("Please input two non-negative numbers as a employee's working hours in one week and salary per hour.\n");
printf("Notice that the salary per hour can't be greater than 1000\nAlso you can't input more than 10 sets of data\n");
printf("Input them like this:\n20,34\nthen enter the Enter key\n");
while(scanf("%lf,%lf",&wh,&sh) == 2 && num < 10)
{
if(sh <0 || wh <0)
{
printf("Salary per hour or salary per hour can't be negative!\n");
}
else if(wh > 168)
{
printf("Working hours in one week can't be more than 168!\n");
}
else if(sh > 1000)
{
printf("Salary can't be greater than 1000!\n");
}
else
{
num ++;
if(wh <= 40)
{
if(sh <= 1000)
{
salary = wh * sh;
}
else if(sh > 1000)
{
salary = wh * 1000;
}
}
else if(wh > 40 && wh <= 50)
{
if(sh*1.5 < 1000)
{
salary = 40*sh + (wh-40)*1.5*sh;
}
else if(sh*1.5 > 1000 && sh < 1000)
{
salary = 40*sh + (wh-40)*1000;
}
else if(sh > 1000)
{
salary = wh * 1000;
}
}
else if(wh > 50)
{
if(sh*3 < 1000)
{
salary = 40*sh + 10*1.5*sh + (wh-50)*3*sh;
}
else if(sh*1.5 < 1000 && sh*3 >=1000)
{
salary = 40*sh + 10*1.5*sh + (wh-50)*1000;
}
else if(sh*1.5 >= 1000 && sh <= 1000)
{
salary = 40*sh + (wh-40)*1000;
}
else if(sh > 1000)
{
salary = wh*1000;
}
}
printf("The total working hours is %lf, and salary per hour is %lf, salary is %lf\n",wh,sh,salary);
}
}
return 0;
}
:
여기 내 C 프로그램입니다.
내가 테스트 데이터가 포함 된 파일을 가정은 다음과 같이이다 :
1,2
34,34
67,43
...
난 정말이 테스트 자동화 작품, 도와주세요 어떻게 아무 생각이 없다! 에서
어떻게이 자동화 테스트를 호출 할 수 있습니까? – Gnijuohz
글쎄, 나는 내 마음을 바꿨다. 그것은 좋은 대답 :) – Gnijuohz