题目
A.def def
B.abc def
C.abc d
D.d d
第1题
执行以下程序后,test.txt文件的内容是(若文件能正常打开) ()。#include <stdio.h>#include <stdlib.h>main(){ FILE * fp; char * s1 = "Fortran" , * s2 = "Basic"; if((fp = fopen("test. txt" ," wb" )) = = NULL) { prinff("Can't open test. txt file \n"); exit(1); } fwrite(s1 ,7,1 ,fp); /* 把从地址s1开始到7个字符写到fp所指文件中*/ fseek(fp,OL,SEEK_SET); /*文件位置指针移到文件开头*/ fwrite (s2,5,1,fp); felose (fp);}
A.Basiean
B.BasieFortran
C.Basic
D.FortranBasie
第2题
●试题七
阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
以下程序的功能是设计一个栈类stack<T>,并建立一个整数栈。
【程序】
#include<iostream.h>
#include<stdli
B.h>
const int Max=20;∥栈大小
template<class T>
class stack{∥栈元素数组
T s[Max];∥栈顶下标
int top;
public:
stack()
{
top=-1;∥栈顶初始化为-1
}
void push(const T &item);∥item入栈
T pop();∥出栈
int stackempty()const;∥判断栈是否为空
};
template<class T>
void stack<T>::push(const T &item)
{
if(top== (1) )
{
cout<<"栈满溢出"<<endl;
exit (1) ;
}
top++;
s[top]=item;
}
template<class T>
T stack<T>::pop()
{
T temp;
if(top== (2) )
{
cout<<″栈为空,不能出栈操作″<<endl;
exit (1) ;
}
temp=s[top];
top--;
return temp;
}
template<class T>
int stack<T>::stackempty()const
{
return top==-1;
}
void main()
{
stack<int>st;
int a[]={1,2,3,4,5 };
cout<<"整数栈"<<endl;
cout<<"入栈序列:"<<endl;
for(int i=0;i<4;i++)
{
cout<<a[i]<<" ";
(3) ;
}
cout<<endl<<"出栈序列:";
while((4) )
cout<< (5) <<" ";
cout<<endl;
}
第3题
有以下程序:
# include< iostream>
执行这个程序,输出结果是()。
第7题
有以下程序: #include <iostream> #include <fstream> using namespace std; int main () { ofstream ofile; char ch; ofile.open ("abc.txt"); cin>>ch; while (ch!='#' ) { cin>>ch; ofile.put(ch);
A.程序编译时出错
B.abc#
C.abc
D.#
第9题
有以下程序
#include <stdio.h>
#include <string.h>
main()
{ printf("%d\n",strlen ("ATS\n012\1") ); }
程序运行后的输出结果是
A)3
B)8
C)4
D)9
第10题
A.10
B.20
C.0
D.出错
第11题
有以下程序:
include<stdio.h>
include<strin9.h>
main()
{printf{"%d\n",strlen("%d\n",strlen("ATS\n012\|"));}
程序运行后的输出结果是()。
A.3
B.8
C.4
D.9
为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!