第十二次作業總結

來源:互聯網
上載者:User

標籤:定義變數   基礎資料型別 (Elementary Data Type)   組成   can   類型   語言   ble   總結   int   

知識點:
1.結構:結構是一種特殊的構造資料類型。整形,實型等基礎資料型別 (Elementary Data Type)是系統預先設定好的,可以直接定義變數,不過也可以自己定義資料類型。
    struct 結構名{
      類型名 結構成員名1;
      類型名 結構成員名2;
      ......
      類型名 結構成員名n;
    };
    struct是定義結構類型的關鍵字,在struct之後,自己命名一個結構名,必須是一個合法的c標識符。關鍵字和他後面的結構名一起組成一個新的資料類型名。結構的定義用分號結束,因為c語言中把結構的定義看作一條語句。

2.字串
  (1)字串表現形式
    char str[]="1";     用字元數組存放一個字串
    char* str="1";    用字元指標指向一個字串
  (2)輸出
    printf("%s\n",str);
  (3)‘\0’表示字元結束

 

代碼
學生資訊管理

#include<stdio.h>struct student{    int num;    char name[10];    int computer,english,math;    double average;} ;int main(){    int i,n;    struct student s1,max;    printf("請輸入n");    scanf("%d",&n);    printf("請輸入學生學號,姓名,成績\n");    for(i=1;i<=n;i++){        printf("No.%d:",i);        scanf("% d% s% d% d% d",&s1.num,s1.name,&s1.math,&s1.english,&s1.computer);        s1.average=(s1.math+s1.english+s1.computer)/3.0;        if(i==1)max=s1;        if(max.average<s1.average)            max=s1;    }     printf("num:% d,name:% s,average:%.2lf\n",max.num,max.name,max.average);    return 0;}

 

第十二次作業總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.