The local guide expresses his thanks to tourists for their cooperation, patience and understanding.
查看答案
下面程序欲对两个整型变量的值进行交换,以下正确的说法是。main(){int a=10,b=20;printf("(1)a=%d,b=%d\n",a,b);swap(&a,&b);printf("(2)a=%d,b=%d\n",a,b);}swap (int p,int q){int t;t=p;p=q;q=t;}
A. 该程序完全正确
B. 该程序有错,只要将语句swap(&a,&b);中的参数改为a,b即可
C. 该程序有错,只要将swap()函数中的形参p、q和变量t均定义为指针即可
D. 以上说法都不正确
下面程序段是把从终端读入的一行字符作为字符串放在字符数组中,然后输出,请分析程序填空。int i;char s[80],*p;for(i=0;i<79;i++){s[i]=getchar();if(s[i]=='\n') break;}s[i]=【1】 ;p=【2】 ;while(*p) putchar(*p++);
设有以下程序片段:char a[ ]="hello!",*p;p=a;printf("%d",*(p+5));执行上面的程序片段后的结果为_____.
下面程序是判断输入的字符串是否是”回文”,(顺读和倒读都一样的字符串,称”回文”,如level)。#include "stdio.h"#include "string.h"main(){char s[81],*p1,*p2;int n;printf("Input a string:");gets(s);n=strlen(s);p1=s;p2=【1】;while (p1