下列程序的运行结果为【14】#include <stdio.h>#include <string.h>struct A{int a;char b[10];double c;};void f (struct A *t);main(){struct A a=(1001,”ZhangDa”,1098,0);f(&a);printf(“&d,&s,&6,if\n”,a.a,a.b,a.c);}void f(struct A *t){strcpy(t->b,”ChangRong”); }

题目

下列程序的运行结果为【14】

#include <stdio.h>

#include <string.h>

struct A

{int a;char b[10];double c;};

void f (struct A *t);

main()

{struct A a=(1001,”ZhangDa”,1098,0);

f(&a);printf(“&d,&s,&6,if\n”,a.a,a.b,a.c);

}

void f(struct A *t)

{strcpy(t->b,”ChangRong”); }


相似考题
更多“下列程序的运行结果为【14】 #include &lt;stdio.h&gt; #include &lt;string.h&gt; struct ”相关问题
  • 第1题:

    有以下程序includemain(){int a=5,b=lt; t=(a<<2)|b;printf("%d\n",t);}程序运行后的

    有以下程序 #include<stdio.h> main() { int a=5,b=lt; t=(a<<2)|b;printf("%d\n",t); } 程序运行后的输出结果是______。

    A.21

    B.11

    C.6

    D.1


    正确答案:A
    解析:本题主要考查了C语言的逻辑运算符,先将变量a,b的值转换为2进制数,a=00000101,b=00000001,a先左移 2位结果为00010100,再与b按位或运算,结果为00010101,转换为十进制数为21,因此,选项A是正确的。

  • 第2题:

    有以下程序:

    若运行时输入:2 4 6<;回车>;,则输出结果为( )。

    A.2 0 4

    B.2 0 0

    C.2 4 0

    D.2 4 6


    正确答案:A
    本题中输入的3个数据2,4,6分别赋值给了x[0[0],x[1][0],x[2][0]。x[o][1]仍为初始时的0,所以打印输出时的结果为A选项。

  • 第3题:

    阅读以下程序,给出运行结果 #include <iostream> #include <cstring> using namespace std; int main() { string str="I love China!"; cout << str; return 0; }


    emoclew emoclew

  • 第4题:

    以下程序的运行结果是【】。 include include using namespace std; void main()

    以下程序的运行结果是【 】。

    include<iostream>

    include<string>

    using namespace std;

    void main(){

    chara[10]="China",b[]="Chin",c[]="ese";

    cout<<strlen(strcat(strcpy(a,b),c))<<endl;

    }


    正确答案:7
    7 解析:本题主要考查C++中字符串函数的使用。strcpy(s1,s2)将s2的内容赋值到s1中; strcat(s1,s2)连接s1和s2两个字符串;strlen(s)返回字符数组s的长度。因此最后输出的结果是b和c进行连接后的字符串长度,即7。

  • 第5题:

    下列表达式结果为“真”的是

    A.2 #gt# 3 #and# 4 #gt# 2 ;

    B.2 #lt# 3 #and# 4 #lt# 2 ;

    C.2 #gt# 3 #and# 4 #lt# 2 ;

    D.2 #lt# 3 #and# 4 #gt# 2;


    [AB]$“ABCDEFGH”

  • 第6题:

    3、阅读下列程序,则在执行后,程序的运行结果为()  #include <string.h> #include<stdio.h> int main() { char a[30]="nice to meet you!"; strcpy(a+strlen(a)/2,"you"); printf("%s\n",a); }

    A.nice to meet you you

    B.nice to

    C.meet you you

    D.nice to you


    D 在C中,数据只能从实际参数单向传递给形参。