Hello:
I am trying to do this assignment: http://icpcres.ecs.baylor.edu/online...m&problem=1464
This is the code which I have completed already:
However; as you can see on that website; there needs to be two lines of input and the 2 lines of output. How do I loop it so I can collect more then 1 line of input? The assignment does not say how many lines of input nor does it ask to collect it from the user. So I do not understand. Right now my application collects two inputs and then prints out 1 line of output and breaks. How else should I do this?Code:int main(int argc, char *argv[]) { int n,a,i,sum=0; scanf("%d",&n); scanf("%d",&a); for(i=1; i<=n; i++) { int calc,x,final_a = a; for(x=1;x<i;x++) { final_a = final_a * a; } calc = i * final_a; sum = sum + calc; } printf("%d\n",sum); }



LinkBack URL
About LinkBacks


