云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 北京理工大学计算机复试上机题00-12

北京理工大学计算机复试上机题00-12

  • 62 次阅读
  • 3 次下载
  • 2025/6/15 8:59:52

/*while(!a.empty()) { cout<

while(!a.empty()) { }

b.push(a.top()); a.pop();

/*while(!b.empty()) {

cout<

}*/

stack t;

while(!b.empty()) { if(b.top()>='0' && b.top()<='9')

{

t.push(b.top()-'0'); b.pop(); } else {

if(b.top()=='+') { }

int c,d; c=t.top(); t.pop(); d=t.top(); t.pop(); t.push(c+d);

if(b.top()=='-') {

int c,d; c=t.top(); t.pop(); d=t.top(); t.pop();

t.push(d-c); }

if(b.top()=='*')

}

}

{

int c,d; c=t.top(); t.pop(); d=t.top(); t.pop(); t.push(c*d);

}

if(b.top()=='/') {

int c,d; c=t.top(); t.pop(); d=t.top(); t.pop(); t.push(d/c);

}

b.pop();

cout<

}

2011年上机及答案1

1.输入一组单词(区分大小写),统计首字母相同的单词个数,相同的单词不累加,输出格式“字母,以该字母为首的单词个数。

//输入一组单词(区分大小写),统计首字母相同的单词个数

//相同的单词不累加,输出格式\字母,以该字母为首的单词个数。 #include #include #include #include using namespace std; int main(int argc, char* argv[]) {

vector str; string s,s1;

while(cin>>s) str.push_back(s);

sort(str.begin(),str.end());

vector::iterator end_unique=unique(str.begin(),str.end()); str.erase(end_unique,str.end()); int i=0,count=0;

char c;

while(i

count++; i++;

s1=str[i]; while(s1[0]==c&&i

{ }

count++; i++; s1=str[i];

cout<

} return 0; }

2.输入一组单词,(区分大小写),输出这些单词的字典排序。。。 //输入一组单词(区分大小写),输出这些单词的字典排序 #include #include #include #include #include using namespace std; int main() { vector str;

string s;

while(cin>>s)

str.push_back(s);

stable_sort(str.begin(),str.end()); int j;

for(j=0;j

if(str[j][0]>=97) break; vector str2; int n=0; int k=j;

string c1,c2;

while(n

c1=str[n];

c2=str[k];

c2[0]=toupper(c2[0]); if(c2[0]

str2.push_back(str[k]); k++;

}

if(c2[0]>c1[0]) {

str2.push_back(str[n]); n++;

}

if(c2[0]==c1[0])

{

if(c1<=c2)

{ str2.push_back(str[n]); str2.push_back(str[k]);

n++; k++;

}

if(c1>c2) { str2.push_back(str[k]); }

str2.push_back(str[n]); n++; k++; }

}

while(n

{

str2.push_back(str[n]);

}

n++;

while(k

str2.push_back(str[k]); k++;

{

}

for(vector::size_type i=0;i

搜索更多关于: 北京理工大学计算机复试上机题00-12 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

/*while(!a.empty()) { cout<='0' && b.top()<='9') { t.push(b.top()-

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com