c語言不會的題,c語言完全不會

本文目錄一覽:

大一初學C語言有若干不會的題,求解

///第一題改錯:

#include stdio.h

mian()

{

int r2=5;//變量名不能為數字開頭,將2r改成r2即可

char _3x=’A’;//同上變量名不能以-號開頭,將-改成_即可,或者改成x3也行

double i=10.5;//不能將關鍵字void作為變量名稱,這裡我把變量名稱命名為i,即改成:double i = 10.5;

printf(“r2=%d, _3x=%c, i =%f\n”,r2,_3x, i);//這句就將上面改過名字替換就行了

}

//第二題:

//計算56,80,79這3個整數的平均值。在工作區下建立工程sy02p2,並建立源程序sy02p2.c,拷備以下代碼到sy02p2.c中,以下程序已經實現計算過程的主要代碼,在(1)和(2)兩處補充相應的變量定義,使得該程序能夠正確執行並顯示出正確結果,提交sy02p2.c到本題答案處。

#include stdio.h

main()

{

int a,b,c;

float s;

a=55;

b=80;

c=79;

s=(a+b+c)*1.0/3;

printf(“s=%f\n”,s);

}

//望採納!!!

關於C語言有幾道題不會,求助大神

C正確,選C——下標從0開始,所以a[2]的值是3,a[a[2]]就是a[3],顯然a[3]是第4個數值是4。

C

A

沒有正確選項,輸出是23

C

C

A

C

C

沒有正確選項,應該是fun(10,12.5);這種形式

B

C語言題目如下,實在不會

/* 第一題如下 */

#include stdio.h

#include stdlib.h

typedef struct Student {

    char name[16];

    int math;

    int english;

    int computer;

    int average;

} Student;

int compare_student_by_average(const Student *, const Student *);

void get_string(char *, size_t);

#define N 5

int main(void) {

    Student students[N];

    int i;

    for (i = 0; i  N; ++i) {

        printf(“Enter the name of the student: “);

        get_string(students[i].name, 16);

        printf(“Enter the math, English and computer of the student: “);

        scanf(“%d %d %d%*c”,

            students[i].math, students[i].english, students[i].computer);

        students[i].average =

            (students[i].math + students[i].english + students[i].computer) / 3;

    }

    qsort(students, N, sizeof(Student),

        (int (*) (const void *, const void *))compare_student_by_average);

    for (i = 0; i  N; ++i) {

        if (students[i].average = 60)

            printf(“%16s %3d %3d %3d\n”, students[i].name, students[i].math,

                students[i].english, students[i].computer);

    }

    return 0;

}

int compare_student_by_average(const Student *s1, const Student *s2) {

    return (s1-average  s2-average ? 1 :

                (s1-average == s2-average ? 0 : -1));

}

void get_string(char *str, size_t size) {

    size_t i = 0;

    int ch = 0;

    while ((ch = getchar()) != ‘\n’)

        if (i  size)

            str[i++] = (char)ch;

    str[i] = ‘\0’;

}

第二題

#include stdio.h

#include stdlib.h

typedef struct Student {

    char name[16];

    int math;

    int english;

    int computer;

    int average;

} Student;

int compare_student_by_average(const Student *, const Student *);

void get_string(char *, size_t);

int main(void) {

    Student *students;

    int i, N;

    printf(“Enter the number of the students: “);

    scanf(“%d%*c”, N);

    students = malloc(sizeof(Student) * N);

    for (i = 0; i  N; ++i) {

        printf(“Enter the name of the student: “);

        get_string(students[i].name, 16);

        printf(“Enter the math, English and computer of the student: “);

        scanf(“%d %d %d%*c”,

            students[i].math, students[i].english, students[i].computer);

        students[i].average =

            (students[i].math + students[i].english + students[i].computer) / 3;

    }

    qsort(students, N, sizeof(Student),

        (int (*) (const void *, const void *))compare_student_by_average);

    for (i = 0; i  N; ++i)

        printf(“%16s %3d %3d %3d\n”, students[i].name, students[i].math,

            students[i].english, students[i].computer);

    return 0;

}

int compare_student_by_average(const Student *s1, const Student *s2) {

    return (s1-average  s2-average ? 1 :

                (s1-average == s2-average ? 0 : -1));

}

void get_string(char *str, size_t size) {

    size_t i = 0;

    int ch = 0;

    while ((ch = getchar()) != ‘\n’)

        if (i  size)

            str[i++] = (char)ch;

    str[i] = ‘\0’;

}

關於C語言作業有幾道題不會,求助

單選題:

1、以下可作為函數 fopen 中第一個參數的正確格式是

C

A、c:\user\file.txt

B、”c:\user\file.txt”

C、”c:\\user\\file.txt

D、c:user\file.txt

2、已知結構體類型定義和變量說明,下面賦值語句中正確的是_____。 struct complex { float re,im; }z;

D 應該是z.re=10.0

A、re=10.0;

B、complex.re=10.0;

C、z→re=10.0;

D、zre=10.0

3、以下敘述中正確的是_____。

B

A、全局變量的作用域一定比局部變量的作用域範圍大

B、靜態(static)類別變量的生存期貫穿於整個程序的運行期間

C、函數的形參都屬於全局變量

D、未在定義語句中賦初值的auto變量和static變量的初值都是隨機值

4、下列敘述中錯誤的是______。

A

A、主函數中定義的變量在整個程序中都是有效的

B、在其它函數中定義的變量在主函數中也不能使用

C、形式參數也是局部變量

D、複合語句中定義的變量只在該複合語句中有效

5、在一個C源程序文件中,若要定義一個只允許在該源文件中所有函數使用的變量,則該變量需要使用的存儲類別是______。

C

A、extern

B、register

C、auto

D、statlc

判斷題:

1、 已知char ch[]=“good!!!”;則字符數組ch的長度是7。

2、變量的指針就是指向該變量指針變量的值。

原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/159206.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
小藍的頭像小藍
上一篇 2024-11-19 18:57
下一篇 2024-11-19 18:57

相關推薦

  • AES加密解密算法的C語言實現

    AES(Advanced Encryption Standard)是一種對稱加密算法,可用於對數據進行加密和解密。在本篇文章中,我們將介紹C語言中如何實現AES算法,並對實現過程進…

    編程 2025-04-29
  • 學習Python對學習C語言有幫助嗎?

    Python和C語言是兩種非常受歡迎的編程語言,在程序開發中都扮演着非常重要的角色。那麼,學習Python對學習C語言有幫助嗎?答案是肯定的。在本文中,我們將從多個角度探討Pyth…

    編程 2025-04-29
  • Python被稱為膠水語言

    Python作為一種跨平台的解釋性高級語言,最大的特點是被稱為”膠水語言”。 一、簡單易學 Python的語法簡單易學,更加人性化,這使得它成為了初學者的入…

    編程 2025-04-29
  • OpenJudge答案1.6的C語言實現

    本文將從多個方面詳細闡述OpenJudge答案1.6在C語言中的實現方法,幫助初學者更好地學習和理解。 一、需求概述 OpenJudge答案1.6的要求是,輸入兩個整數a和b,輸出…

    編程 2025-04-29
  • Python按位運算符和C語言

    本文將從多個方面詳細闡述Python按位運算符和C語言的相關內容,並給出相應的代碼示例。 一、概述 Python是一種動態的、面向對象的編程語言,其按位運算符是用於按位操作的運算符…

    編程 2025-04-29
  • Python語言由荷蘭人為中心的全能編程開發工程師

    Python語言是一種高級語言,很多編程開發工程師都喜歡使用Python語言進行開發。Python語言的創始人是荷蘭人Guido van Rossum,他在1989年聖誕節期間開始…

    編程 2025-04-28
  • Python語言設計基礎第2版PDF

    Python語言設計基礎第2版PDF是一本介紹Python編程語言的經典教材。本篇文章將從多個方面對該教材進行詳細的闡述和介紹。 一、基礎知識 本教材中介紹了Python編程語言的…

    編程 2025-04-28
  • Python語言實現人名最多數統計

    本文將從幾個方面詳細介紹Python語言實現人名最多數統計的方法和應用。 一、Python實現人名最多數統計的基礎 1、首先,我們需要了解Python語言的一些基礎知識,如列表、字…

    編程 2025-04-28
  • Python作為中心語言,在編程中取代C語言的優勢和挑戰

    Python一直以其簡單易懂的語法和高效的編碼環境而著名。然而,它最近的發展趨勢表明Python的使用範圍已經從腳本語言擴展到了從Web應用到機器學習等廣泛的開發領域。與此同時,C…

    編程 2025-04-28
  • Python基礎語言

    Python作為一種高級編程語言擁有簡潔優雅的語法。在本文中,我們將從多個方面探究Python基礎語言的特點以及使用技巧。 一、數據類型 Python基礎數據類型包括整數、浮點數、…

    編程 2025-04-28

發表回復

登錄後才能評論