c语言判断素数_易错题之大一C语言&英语

bc27c778128f805ea5b4eba885048fc3.gif

点击蓝字关注我们

195e4eb971302c98bb8ce3477db69d3d.png

C语言

01

1.指针填空

Description

用指针统计字符串中英文字母、数字的个数

输入一行字符,用指针统计字符串中英文字母和数字(字符串中只有英文字符和数字)主要代码已经给出,请补充缺少的部分。

#include

#include

#include

#define Maxsize 10000

int main()

{

    char *p;

    int sum1=0,sum2=0;

    p=(char *)malloc(sizeof(char)*Maxsize);

    scanf("%s",p);

    while(*p)

    {

          /*******************************

                 请在该部分补充缺少的代码

           ********************************/

    }

    printf("%d %d\n",sum1,sum2);

    return 0;

}

Input

一行字符串

Output

统计值

Sample Input

abcdefghi123456789

Sample Output

9 9

答案

#include

#include

#include

#define Maxsize 10000

int main()

{

    char *p;

    int sum1=0,sum2=0;

    p=(char *)malloc(sizeof(char)*Maxsize);

    scanf("%s",p);

    while(*p)

    {

        if((*p>='a'&&*p<='z')||(*p>='A'&&*p<='Z'))//word

        {

            sum1++;

        }

        if(*p>='0'&&*p<='9')//number

        {

            sum2++;

        }

        p++;//next

    }

    printf("%d %d\n",sum1,sum2);

    return 0;

}

02

判断素数

Description

写一个判断素数的函数,在主函数输入一个整数,输出是否是素数的消息。

Input

一个数

Output

如果是素数输出prime 如果不是输出not prime

Sample Input

97

Sample Output

prime

HINT

  主函数已给定如下,提交时不需要包含下述主函数

/*  C代码  */

int main(){

    int flag,n;

    int is_prime(int);  

    scanf("%d",&n);

    flag=is_prime(n);

    if(flag==1)

        printf("prime\n");

    else

        printf("not prime\n");

    return 0;

}

【注意】:提交时头文件也要提交

【AC代码】:

#include

using namespace std;

int is_prime(int n)

{

    for(int i=2;i

        if(n%i==0)

        return 0;

    return 1;

}

答案

#include 
#include 
int main()
{
int i = 100;
int count = 0;
for (; i <= 200; i++)  //遍历需要求的数100-200
{
int j = 2;
for (; j  {
if (i%j == 0)
{
break;
}
}
if (i == j)
{
printf("%d ", i);
count++;
}
}
printf("\ncount = %d\n", count);
system("pause");
return 0;
}

03

对称矩阵

Description

已知A和B为两个n*n阶的对称矩阵,输入时,对称矩阵只输入下三角行元素,存入一维数组,设计一个程序,实现以下功能。

1、求对称矩阵A和B的和。

2、求对称矩阵A和B得到乘积。

Input

输入包含两行,第一行为一个整数N,接下来为N个整数。N满足(N=n+n*(n-1)/2)n为矩阵的行数。

Output

输出对称矩阵A和B的和与乘积,中间留有一个空行!

Sample Input

2

1 2 3

1 2 3

Sample Output

2 4

4 6

5 8

8 13

答案

#include

#include

int main()

{

    int n,i,j,m=0,k=0,a[10],b[10],a1[10][10],b1[10][10],x,temp,c[10][10],l;

    scanf("%d",&n);

    for(i=0;i

    {

        do

        {

            scanf("%d",&a[m]);

            m++;

        }

        while(getchar()!='\n');

        do

        {

            scanf("%d",&b[k]);

            k++;

        }

        while(getchar()!='\n');

        l=(-1+sqrt(1+8*m))/2;

        for(i=0; i

        {

            for(j=0; j<=i; j++)

            {

                a1[j][i]=a1[i][j]=a[i+j];

                b1[j][i]=b1[i][j]=a[i+j];

            }

        }

        for(i=0; i

        {

            for(j=0; j

            {

                if(j!=l-1)

                    printf("%d ",a1[i][j]+b1[i][j]);

                else

                    printf("%d",a1[i][j]+b1[i][j]);

            }

            printf("\n");

        }

        printf("\n");

        for(i=0; i

        {

            for(j=0; j

            {

                temp=0;

                for(x=0; x

                {

                    temp+=a1[x][j]*b1[i][x];

                }

                c[i][j]=temp;

                if(j!=l)

                    printf("%d ",c[i][j]);

                else

                    printf("%d",c[i][j]);

            }

            printf("\n");

        }

    }

    return 0;

04

判断字符串是否为回文

编写程序,判断输入的一个字符串是否为回文。若是则输出“Yes”,否则输出“No”。所谓回文是指順读和倒读都是一样的字符串。

样例输入

abcddcba

样例输出

Yes

答案

#include

int main()

{

    char a[50],b[50];

    int i,j,n;

    scanf("%s",&a);

    n=strlen(a);

    for(i=0,j=n-1;i=0;i++,j--)

    {

        b[j]=a[i];

    }

    for(i=0;i

    {

        if(b[i]!=a[i])

        break;

    }

    if(i==n)

        printf("Yes");

    else

        printf("No");

    return 0;

}

06

将十进制数对应的八进制、十六进制、十进制数输出

Description

输入一个十进制数,转换为对应的八进制、十六进制、十进制数输出

Input

输入一个十进制数

Output

输出该十进制数对应的八进制、十六进制、十进制数

Sample Input

10

Sample Output

oct:12

hex:a

dec:10

HINT

使用输出格式控制符  dec    oct    hex

答案

#include

#include

int main()

{

    int a;

    scanf("%d",&a);

    printf("oct:%o\n",a);

    printf("hex:%x\n",a);

    printf("dec:%d",a);

    return 0;

}

07

打印出所有"水仙花数

Description

打印出所有"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该本身。例如:153是一个水仙花数,因为153=1^3+5^3+3^3。

 Output:

153

???

???

???

Input

Output

所有的水仙花数,从小的开始。每行一个

答案

#include

#include

int main()

{

   int i,g,s,b;

  for(i=100;i<=999;i++)

  {

      g=i%10;

      s=i/10%10;

      b=i/100%10;

      if(i==g*g*g+s*s*s+b*b*b)

        printf("%d\n",i);

  }

    return 0;

}

英语

01

1. The football game comes to you ________ from New York.

A) lively B) alive C) live D) living

2. The author of the report is well ________ with the problems in the

hospital because he has been working there for many years.

A) informed B) acquainted C) enlightened D) acknowledged

3. The ship's generator broke down, and the pumps had to be operated

________ instead of mechanically.

A) manually B) artificially C) automatically D) synthetically

4. The machine looked like a large, ______, old-fashioned typewriter.

A) forceful B) clumsy C) intense D) tricky

5. Considering your salary, you should be able to _____ at least twenty dollars a week.

A) put forward B) put up C) put out D) put aside

6. As he has _____ our patience, we'll not wait for him any longer.

A) torn B) wasted C) exhausted D) consumed

7. These teachers try to be objective when they ___ the integrated ability of their students.

A) justify B) evaluate C) indicate D) reckon

8. Tomorrow the mayor is to ____ a group of Canadian businessmen on a tour of the city.

A) coordinate B) cooperate C) accompany D) associate

9. I'm _____ enough to know it is going to be a very difficult situation

to compete against three strong teams.

A) realistic B) conscious C) aware D) radical

10. As an actor he could communicate a whole _____ of emotions.

A) frame B) range C) number D) scale

答案

1. [C] 本题为话题同现,足球比赛直播英语为live。

2. [B] 本题为搭配题,be acquainted with 表示 "对…熟悉,了解"。

3. [A] 本题为对立同现,与mechanically相对的应该是manually,即手工。其他选项automatically(自动地) artificially(人工地,假), synthetically (综合底)都与mechanically不构成同现关系

4. B。 clumsy“笨拙的,粗陋的”,这个词很好的形容了打字机的笨重;forceful “有力的”;intense“强烈的,剧烈的”;tricky“狡猾的,机警的”。

[译文] 这台机器看起来像一个巨大、简陋而又过时的打字机。

5. D。put aside“撇开,储蓄…备用”,符合句中“储蓄,存钱”的含义;put forward“提出,推举出”;put up“建造,举起,提供,提名”;put out“放出,伸出”。

[译文] 考虑到你的薪资情况,你每星期至少可以存二十美元。

6. C。exhausted“耗尽的,疲惫的”,是exhaust的过去分词;torn“破的”,是tear的过去分词;wasted“废弃的,荒芜的,多余的”;consumed“消耗的,消灭的”,多指具体有形物品的消耗。

[译文] 既然他已经耗尽了我们的耐心,我们也就不再等他了。

7. B。evaluate“评价,估计”,是及物动词,后面可以直接加宾语;justify “证明…是正当的,为…辩护”;indicate“指出,象征”;reckon“计算,估计”,常用的搭配是reckon on/upon“依赖,依靠;对…做出假设,设想…。”

[译文]老师在评价学生的综合能力时力图客观。

8. C。accompany“陪伴,伴奏”,accompany指“与人结伴,做伴”,常含有彼此之间关系平等之意;coordinate“调整,整理”;cooperate“合作,协作”, cooperate with sb.In sth.“和某人合作某事”;associate“使联合,交往”, associate with“和…来往,和…共事,同…联合;(在思想上) 同…联系在一起”。

[译文]明天市长要陪同一组加拿大商人游览这个城市。

9. B。conscious“有意识的,有知觉的”;realistic“现实的,现实主义的,实际的”;aware“知道的,明白的”,常与of连用;radical“根本的,基本的”。

[译文]我深深的意识到与这三组实力很强的对手竞争是很困难的。

10. B。range“行列,范围”,通常的搭配是a range of,如:a range of knowledge 即“知识丰富”;frame“结构,体格”;number“数量”;scale“刻度,比例”。

[译文]作为一个演员,他感情丰富。

02

Questions 21 to 25 are based on the following passage:

  It is simple enough to say that since books have classes fiction, biography, poetry—we should separate them and take from each what it is right that each should give us. Yet few people ask from books what books can give us. Most commonly we come to books with blurred and divided minds, asking of fiction that it shall be true, of poetry that it shall be false, of biography that it shall be flattering, of history that it shall enforce our own prejudices. If we could banish all such preconception when we read, that would be an admirable beginning. Do not dictate to your author; try to become him. Be his fellow worker and accomplice(同谋). If you hang back, and reserve and criticize at first, you are preventing yourself from getting the fullest possible value from what you read. But if you open your mind as widely as possible, then signs and hints of almost imperceptible finess(委婉之处), from the twist and turn of the first sentences, will bring you into the presence of a human being unlike any other. Steep yourself in this, acquaint yourself with this, and soon you will find that your author is giving you, or attempting to give you, something far more definite. The thirty two chapters of anovel—if we consider how to read a novel first—are an attempt to make something as formed and controlled as a building but words are more impalpable than bricks, reading is a longer and more complicated process than seeing. Perhaps the quickest way to understand the elements of what a novelist is doing is not to read, but to write; to make your own experiment with the dangers and difficulties of words. Recall, then, some event that has left a distinct impression on you—how at the corner of the street, perhaps, you passed two people talking. A tree shook; an electric light danced; the tone of the talk was comic, but also tragic; a whole vision, an entire conception, seemed contained in that moment.

  1.What does the author mean by saying “Yet few people ask from books what books can give us.”?

  A.The author means that lots of people read few books.

  B.The author thinks that readers have only absorbed part of knowledge in books.

  C.The author holds that few people have a proper idea about what content some kind of books should include.

  D.The author considers that readers can scarcely understand most of the books.

  2.According to the passage, which of the following statement is right?

  A.A reader should find some mistakes when he is reading.

  B.The more difficult a book is, the more you can get from it.

  C.To read something is easier than to watch something.

  D.One should be in the same track with the writer when he is reading.

  3.What is the possible meaning of “impalpable” (Paragraph 2) in the passage?

 A.Clear. B.Elusive. C.Delicate. D.Precise.

  4.What’s the main idea of this passage?

    A.The importance of reading. 

        B.The proper way to read.

      C.How to get most from one book. 

        D.The characters of a good book.

  5.When a writer is writing he often get the whole conception ____.

  A.after a long time’s thinking

  B.through an instant inspiration

  C.according to his own experience

 D.by way of watching the objects attentively

1.答案C。解答此题,正确理解“Yes…us”一句含义是 关键。其实质含义是:“许多人读书时因观念不正确,而仅仅能从书本中得到很少的知识获得很少的启迪”。这样,我们 就可以对选项进行逐个分析取舍了。A项意为“作者认为许多人读的书都太少”,显然与我 们的分析不符。B项意为“作者认为读者仅仅从书中汲取了部分知识。”这句话只是引文部 分的字面含义,所以也应排除。再看C项作者认为许多人对某类书应该包含什么样的内容没 有正确的观念。这才是作者的隐含意思,所以是正确的。而D项“作者认为许多读者对大量 的书都不能读懂。”这也是一种错误的理解,也应排除。这样就可确定选项为C。

  2.答案D。此题只能用排除法,去掉与文章细节不符的选 项。选项A意为“读者在阅读时应该能发现一些错误。”文章中没有此细节,可排除。B项“一本书越难读,从中得到知 识也越多。”也与文意无关。再看C项“阅读比观看容易。”根据文章第二段第四句最后一分句可知这正与作者的观点相反,故也排除。最后只剩下D项,应为正确答案。而其内容“读者在阅读时应和作者保持一致。”正是作者的观点,无疑正确。

  3.答案B。先看上文:作家想把素材安排得像一座完整的大房,使之具体化。接下来就是含有“impalpable”一句。句首用“but”引导,有转折含义。所以此单词意义可能与“具体”相对。再看下文,阅读比观看更复杂和费时。这样,该词的含义就可以基本确定了,应该是“非常抽象难以捉摸的”之类的意思。(这里与”砖头”相比,更加强了这一点)据此可 排除A、D项。C项意为“微妙”,意近。但B项恰好意为“难以捉摸的”,更与生词含义接近 ,所以应选B。此题目C项干扰性较大,注意要避免匆忙选择,而功亏一篑。

  4.答案B。解答此题关键在于先弄清文章的主旨和大意。 在此基础上就可进行选弃了。此短文主要讲“何为正确的读书方法”。据此,A项“阅读的重要性”,C项“如何从书中获 取最多的信息”,D项“一本好书的特征”,均不能选。而B项“何为正确的读书方法”,正与我们的分析不谋而合,所以B为正确答案无疑。

  5.答案B。答案可从文章最后一句获得。解答此类题的关 键就是找到并正确理解有关细节。根据最后一句可知“作家构思的获得是通过瞬间的感悟。”可确定:B项为正确答案。

32b0f11a7be0b589b29cf52bafb86479.png

计算机与控制工程学院
团学组织宣传部

文字内容来自学习部

 本期编辑 / 胡志信
 责任编辑 / 杨金广
  校 审 / 蔡金晶

03a9253208e609137c6f2c41ccff77ff.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值