#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int coefficient,index;
while(cin>>coefficient>>index)
{
if(index > 1)
cout<<coefficient * index<<" "<<index - 1<<" ";
else if (index == 1)
cout<<coefficient * index<<" "<<index - 1;
else if(index == 0 && coefficient == 0)
cout<<"0 0";
}
return 0;
}
这个代码只有19分,在格式上一直无法考虑周全,后来看到大神做的,就没想到FLAG!!!
#include <iostream>
using namespace std;
int main() {
int a, b, flag = 0;
while (cin >> a >> b) {
if (b != 0) {
if (flag == 1) cout << " ";
cout << a * b << " " << b - 1;
flag = 1;
}
}
if (flag == 0) cout << "0 0";
return 0;
}