这个是我现在写的程序,是可以显示出图片,但是我觉得应该可以更简单的方法,希望可以指点下[code]#include <stdio.h>
#include <gd.h>
int main()
{
FILE *jpgFile = NULL;
gdImagePtr gdImage =gdImageCreate (600,200);
int black;
int red;
int a,b,c,d;
scanf("%1d%1d%1d%1d",&a,&b,&c,&d);
black = gdImageColorAllocate(gdImage, 0, 0, 0);
red = gdImageColorAllocate(gdImage, 255, 0, 0);
gdImageSetPixel(gdImage, 60, 100, red);
switch (a)
{
case 0 : gdImageFilledEllipse( gdImage, 20, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 100, 20, 20, red );break;
case 1 : gdImageFilledEllipse( gdImage, 40, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 100, 20, 20, red );break;
case 2 : gdImageFilledEllipse( gdImage, 20, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 100, 20, 20, red );break;
case 3 : gdImageFilledEllipse( gdImage, 20, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 100, 20, 20, red );break;
case 4 : gdImageFilledEllipse( gdImage, 20, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 100, 20, 20, red );break;
case 5 : gdImageFilledEllipse( gdImage, 20, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 100, 20, 20, red );break;
case 6 : gdImageFilledEllipse( gdImage, 20, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 100, 20, 20, red );break;
case 7 : gdImageFilledEllipse( gdImage, 20, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 100, 20, 20, red );break;
case 8 : gdImageFilledEllipse( gdImage, 20, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 100, 20, 20, red );break;
case 9 : gdImageFilledEllipse( gdImage, 20, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 20, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 40, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 60, 100, 20, 20, red );break;
}
switch (b)
{
case 0 : gdImageFilledEllipse( gdImage, 100, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 100, 20, 20, red );break;
case 1 : gdImageFilledEllipse( gdImage, 120, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 100, 20, 20, red );break;
case 2 : gdImageFilledEllipse( gdImage, 100, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 100, 20, 20, red );break;
case 3 : gdImageFilledEllipse( gdImage, 100, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 100, 20, 20, red );break;
case 4 :
gdImageFilledEllipse( gdImage, 100, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 100, 20, 20, red );break;
case 5 : gdImageFilledEllipse( gdImage, 100, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 100, 20, 20, red );break;
case 6 : gdImageFilledEllipse( gdImage, 100, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 100, 20, 20, red );break;
case 7 : gdImageFilledEllipse( gdImage, 100, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 100, 20, 20, red );break;
case 8 : gdImageFilledEllipse( gdImage, 100, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 100, 20, 20, red );break;
case 9 : gdImageFilledEllipse( gdImage, 100, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 20, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 40, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 60, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 80, 20, 20, red );
gdImageFilledEllipse( gdImage, 100, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 120, 100, 20, 20, red );
gdImageFilledEllipse( gdImage, 140, 100, 20, 20, red );break;
}