找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1214|回复: 27

晚上赴死,保下佛脚

[复制链接]
发表于 2008-6-25 15:24:16 | 显示全部楼层 |阅读模式
悬赏500FM币已解决
#include<iostream >
using namespace std;
int a[8]={1, 2, 3, 4, 5, 6 , 7 , 8};
void main(){
        int s0,s1,s2;
        s0=s1=s2=0;
        for(int i=0; i<8; i++)
        {switch(a【i】%3)
        {case 0: s0+=a【i】;break;
case 1: s1+=a【i】;break;
case 2: s2+=a【i】;break;
        }
        }
        cout<<s0<<' '<<s1<<' '<<s2<<endl;
}


#include<iostream >
using namespace std;
int count_calls()
{
        static int ctr=-1;
        return ++ctr;
}
int main()
{
        for (int i=0;i!=10;++i)
                cout<<count_calls()<<endl;
        return 0;
}



#include<iostream >
using namespace std;
void swap(int x, int y)
{
        int temp;
        temp =x;
        x=y;
        y=temp;
}
int main()
{
        int xval,yval;
        cout<<"Enter two integers:"<<endl;
        cin >>xval>>yval;
        cout<<"Before swapped: "
                <<"x="<<xval
                <<";y="<<yval<<endl;
        swap(xval,yval);
        cout<<"After swapped: "
                <<"x="<<xval
                <<";y="<<yval<<endl;
        return 0;
}

上面三题请说出运行结果并简单解释

#include<iostream >
#include<string>
#include<cctype>
using namespace std;
int main(){
        string currWord,preWord;
        cout<<"Enter some words:"<<endl;
        while(cin>>currWord)
        {
                if(currWord==preWord && isupper(preWord[0]))
                        break;
                else
                        preWord=currWord;
        }   //注:下面的empty()成员函数判断单词是否为空
        if(currWord==preWord && !currWord.empty())
                cout<<"The repeated word:"<<currWord<<endl;
        else
                cout<<"There is no repeated word."<<endl;
        return 0;
}

说出这个代码的作用

还有谁能列出些常用的函数及他们的意义

[ 本帖最后由 meng1987 于 2008-6-25 04:06 PM 编辑 ]

最佳答案

查看完整内容

第一题有错,无法执行 第二题输出: 0 1 2 3 4 5 6 7 9 第三题 输入两个数,显示交换前与交换后的结果 但实际上两个数并没有交换,因为swap函数的参数是传值的,不影响原来的xval与yval
发表于 2008-6-25 15:24:17 | 显示全部楼层
第一题有错,无法执行
第二题输出:
0
1
2
3
4
5
6
7
9
第三题
输入两个数,显示交换前与交换后的结果
但实际上两个数并没有交换,因为swap函数的参数是传值的,不影响原来的xval与yval
回复

使用道具 举报

发表于 2008-6-25 15:25:08 | 显示全部楼层
好长,不懂帮顶了。。
回复

使用道具 举报

发表于 2008-6-25 15:25:39 | 显示全部楼层
不懂路过

VB刚及格
回复

使用道具 举报

发表于 2008-6-25 15:26:28 | 显示全部楼层
我不要500FMB了~
回复

使用道具 举报

发表于 2008-6-25 15:29:10 | 显示全部楼层
还是抱狒脚吧。。。
回复

使用道具 举报

发表于 2008-6-25 15:35:39 | 显示全部楼层

C++混及格的路过

现在完全看不懂
回复

使用道具 举报

发表于 2008-6-25 15:38:29 | 显示全部楼层
真500块钱,我坚决不要!
回复

使用道具 举报

发表于 2008-6-25 15:38:52 | 显示全部楼层
它认识我我不认识它
over
回复

使用道具 举报

 楼主| 发表于 2008-6-25 15:42:04 | 显示全部楼层
等达人
这个是上届的几道考题
我觉得是这样的话我可以考虑不去考
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|FMFans ( 京ICP备07501235号 )

GMT+8, 2025-5-20 12:57 , Processed in 0.052646 second(s), 11 queries , Gzip On, APCu On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表