pages:
  • 1
Sinash SAYS

what shoud be print exactly : System.out.println("A has " + Ascore + " points. B has " + Bscore + " points./n");

AMiR SAYS

A blank line should separate output lines.

You have to print a blank line between every line.

Amir Havangi SAYS

Hi. Why do I have presntation Error?! I think every thing is true. This is my code:

#include <iostream>
using namespace std;
int main(){
    int n;
    int sum1=0,sum2=0;
    while(1){
            sum1=0;
            sum2=0;
            cin>>n;
            if(n==0)
                    break;
            int* a=new int[n];
            int* b=new int[n];
            for(int i=0;i<n;i++){
                cin>>a[i];
            }
            for(int i=0;i<n;i++){
                cin>>b[i];
            }
            for(int i=0;i<n;i++){
                if(a[i]-b[i]>1)
                    sum1=sum1+a[i];
                else if(a[i]-b[i]==1 && a[i]!=2)
                    sum2=sum2+(a[i]+b[i]);
                else if(a[i]-b[i]==1)
                    sum2=sum2+6;
                else if(b[i]-a[i]>1)
                    sum2=sum2+b[i];
                else if(b[i]-a[i]==1 && b[i]!=2)
                    sum1=sum1+(a[i]+b[i]);
                else if(b[i]-a[i]==1)
                    sum1=sum1+6;
            }

        cout<<"A has "<<sum1<<" points. B has "<<sum2<<" points.";
        if(n!=0)
            cout<<endl<<endl;
}
return 0;

}

AMiR SAYS

In the last lines you have

if(n!=0)
    cout<<endl<<endl;

n will never be 0, because on the top you have checked

if(n==0)
    break;

Run your code through command line, redirect the output to a text file and examine the output. You should print an empty line only between each case.

g++ solution.cpp
./a.out < input.txt > output.txt