请问,您会使用 c 吗?
试试我精心为您定制的6道题,您能指出以下程序存在什么问题吗?(1)
#include <stdio.h>
int* blueguy(void);
int main(void)
{
int *greengirl = NULL;
greengirl = blueguy();
printf("%d", greengirl[0]);
return 0;
}
int* blueguy(void)
{
int a[10] = {1,2,3,4,5,6,7,8,9,10};
return a;
}
(2)
#include <stdio.h>
int main(void)
{
char* blueguy;
scanf("%s", blueguy);
puts(blueguy);
return 0;
}
(3)
#include <stdio.h>
int main(void)
{
char* blueguy = "freengirl";
blueguy[0] = 'g';
puts(blueguy);
return 0;
}
(4)
#include <stdio.h>
int factorial(int n);
int main(void)
{
int blueugy, greengirl ;
scanf("%d", &blueguy);
greengirl = factorial(blueguy);
printf("%d", greengirl);
return 0;
}
int factorial(int n)
{
if(n == 0)
{
return 1;
}
return factorial(n-1) * n;
}
(5)
#include <stdio.h>
#include <stdlib.h>
int main(void)
char *blueguy(void);
int main(void)
{
char *greengirl = blueguy();
greengirl[0] = 'b';
puts(greengirl);
return 0;
}
char *blueguy(void)
{
char *x = malloc(10);
strcpy(x, "alueguy");
return x;
}
(6)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char *a = "blueguy";
char *b = malloc(strlen(a));
strcpy(b, a);
puts(b);
return 0;
}
[ 本帖最后由 BlueGuy 于 2010-5-30 10:54 编辑 ]