Está en la página 1de 2

LABORATORIO 4 Semana 28 de noviembre de 2011

Problema 1
Dado el siguiente código realice la traza del programa utilizando el GDB.
Complete la tabla adjunta.
#include <stdio.h>
main()
{
int a[10],b[10],m=0,i,j,k,l;
a[0]=0;
for(i=0;i<8;i++)
{ a[i+1]=a[i]+1;
b[i]=a[i]*a[i];
}
while (m<=10)
{
for(j=1;j<=5;j++)
{ m++;
k=4*j+10+m+b[j-1]-a[j-1]*a[j-1];
if(k>25) continue;
l=(m+5)/2*k-3*m*m;
printf("%d %d %d %d %d\n",i,j,k,l,m);
}
if(l<-220) break;
printf("%d\n",m);
}
}

i j k l m A[] …. B[] … Pantalla


Al finalizar el ejemplo anterior debe comprender y poder aplicar:
(1) la forma de utilizar los ciclos FOR y WHILE,
(2) la lógica de resolución de IF, BREAK y CONTINUE,
(3) el orden de aplicación de las operaciones matemáticas.

Problem 2 A Mathematical Curiosity

Given two integers n and m, count the number of pairs of integers (a,b) such that 0<a<b<n and
(a2+b2+m)/(ab) is an integer.

INPUT
You will be given a number of cases in the input. Each case is specified by a line containing the
integers n and m. You may assume that 100n>0.

OUTPUT
For each case, print the case number as well as the number of pairs (a,b) satisfying the given
property. Print the output for each case on one line in the format as show below.

Sample Input Sample Output


10 1 Case 1: 2
20 3 Case 2: 4
30 4 Case 3: 5

También podría gustarte