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