South Bronx, N.Y. — In the corner of a classroom at the Spofford Juvenile Center in the South Bronx, two inmates hunch over a computer terminal. From a distance, their exclamations make it clear they are playing basketball (''Slam Dunk'' is its computer name.)
Since it costs $65,000 per inmate (all 17 years old or younger) per year at the maximum security detention center, one might ask: Are taxpayers' dollars being spent for electronic gadgetry to amuse criminals?
A close look at the screen tells a different story. The game may be battleship or bowling, darts or hangman, concentration or baseball, but the content is anything from math or science to geography or spelling.
In ''Slam Dunk,'' there are two players on a basketball court at the bottom of the screen, and at the top a math problem: 4528 EQUALS ? If the problem is answered correctly, a lighted electronic player swishes the ball through the basketball net. After 10 points are scored, one of the figures leaps up and ''slam-dunks'' the ball through the hoop. In a one-hour basketball game, two inmates would have to complete more than 60 multiplication problems.
Each of Spofford's 11 dormitories (with 24 residents per building) has a Commodore PET microcomputer in its day room. The learning center where Spofford residents spend four hours a day in academic classes has another 15 terminals.
''I want computers behind bars to open doors, not close them,'' says Antonia Stone, founder of Playing to Win, a nonprofit foundation committed to providing inmates with the educational benefits of microcomputers. ''The technology is already spreading throughout society and I want inmates, juvenile and adult, to have the same opportunity and access,'' she says.
Ms. Stone says perhaps the greatest reason for footing the bill of computers behind bars is that ''the potential employment for a trained programmer in today's work force is unlimited.'' The former inmates she has trained at The Fortune Society, a nonresidential New York City rehabilitation agency for ex-offenders, ''now have very good, very productive jobs because they can program and help businesses and institutions use the new technology,'' she says.
But can financially strapped penal institutions afford high-technology teaching tools?
''Our cost for seven 'micros' which are in use 60 hours a week in both the classroom and the living quarters comes to 7 cents per user hour,'' says Bill Anthony, director of education at the Milan Federal Penitentiary in Milan, Mich.
Playing to Win plans and designs more than 200 computer programs for correctional institutions. It offers advice on the selection of appropriate machines (hardware); on designing games (software) tailored to the goals and curricula of the prison; and the training of staff in the programming, and maintenance of the system.
''Playing to Win is a meaningful and very vital program,'' says Jonas Halpern , a vice-president at Warner Communications. The company (a New York City cable TV firm, manufacturer of Atari home computers, and owner of the nationwide best-selling video game, ''PacMan'') is so convinced of the value of Playing to Win it gave Ms. Stone a $25,000 grant to run the program for another six months.
''We hope to . . . keep it going on a viable basis,'' says Mr. Halpern. Sites in the primarily poor Brooklyn neighborhoods of Bedford-Stuyvesant and Oceanhill-Brownsville are being considered for community-release inmate learning centers. (Playing to Win, 106 East 85th St. N.Y., N.Y. 10028)