中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

杭州專業(yè)網(wǎng)站制作凡科建站下載

杭州專業(yè)網(wǎng)站制作,凡科建站下載,開鎖換鎖公司網(wǎng)站模板,會(huì)員管理系統(tǒng)代碼目錄 1、計(jì)算學(xué)生平均身高 2、使用指針實(shí)現(xiàn)數(shù)據(jù)交換 3、使用指針實(shí)現(xiàn)整數(shù)排序 5、使用指針輸出數(shù)據(jù)元素 6、使用指針查找數(shù)組中的最大值和最小值。 7、使用指針連接兩個(gè)字符串 8、用指針數(shù)組構(gòu)造字符串?dāng)?shù)組 9、使用指針的指針輸出字符串 10、找出最高分 1、計(jì)算學(xué)生平均…

目錄

1、計(jì)算學(xué)生平均身高

?2、使用指針實(shí)現(xiàn)數(shù)據(jù)交換

3、使用指針實(shí)現(xiàn)整數(shù)排序

5、使用指針輸出數(shù)據(jù)元素

6、使用指針查找數(shù)組中的最大值和最小值。

7、使用指針連接兩個(gè)字符串

8、用指針數(shù)組構(gòu)造字符串?dāng)?shù)組

9、使用指針的指針輸出字符串

10、找出最高分


1、計(jì)算學(xué)生平均身高

輸入學(xué)生數(shù)并逐個(gè)輸入學(xué)生的身高,輸出身高的平均值。

#include<stdio.h>
float average(float arry[],int n);
int main()
{float average(float arry[],int n);float height[100],aver;int i,n;printf("請(qǐng)輸入學(xué)生的數(shù)量:\n");scanf("%d",&n);printf("請(qǐng)輸入學(xué)生們的身高:\n");for(i=0;i<n;i++)scanf("%f",&height[i]);printf("\n");aver=average(height,n);printf("學(xué)生的平均身高為:%6.2f\n",aver);return 0;} float average(float array[],int n){int i;float aver,sum=0;for(i=0;i<n;i++)sum+=array[i];aver=sum/n;return(aver);}

運(yùn)行結(jié)果

?2、使用指針實(shí)現(xiàn)數(shù)據(jù)交換

輸入兩個(gè)整型數(shù)值,將變量a,b中的值交換,然后輸出道窗體上。

#include<stdio.h>
int swap(int *p1, int *p2);
int main()
{int a,b;int *pointer1, *pointer2;scanf("%d%d",&a,&b);pointer1 = &a;pointer2 = &b;swap(pointer1, pointer2);printf("\nThe result is :%d,%d\n",a,b);return 0;
}
swap(int *p1,int *p2)
{int temp;temp = *p1;*p1 = *p2;*p2 = temp;
}

運(yùn)行結(jié)果

3、使用指針實(shí)現(xiàn)整數(shù)排序

輸入三個(gè)整數(shù),將這三個(gè)整數(shù)按照由大到小的順序輸出,顯示在屏幕上。?

#include<stdio.h>
int swap(int *p1,int *p2);
int exchange(int *pt1,int *pt2,int *pt3);
int main()
{int a,b,c,*q1,*q2,*q3;puts("Please input three key numbers you want to rank:");scanf("%d,%d,%d",&a,&b,&c);q1 = &a;q2 = &b;q3 = &c;exchange(q1,q2,q3);printf("\n%d,%d,%d\n",a,b,c);puts("\n Press any key to quit...");return 0;
}
swap(int *p1,int *p2)
{int temp;temp = *p1;*p1 = *p2;*p2 = temp;
}
exchange(int *pt1,int *pt2,int *pt3)
{if(*pt1<*pt2)swap(pt1,pt2);if(*pt1<*pt3)swap(pt1,pt3);if(*pt2<*pt3)swap(pt2,pt3);}

運(yùn)行結(jié)果

?4、指向結(jié)構(gòu)體變量的指針

通過(guò)指向結(jié)構(gòu)體指針變量實(shí)現(xiàn)在窗體上顯示學(xué)生的信息。

#include<stdio.h>
struct student
{int num;char name[20];char sex;int age;float score;
};
int main()
{struct student student1={1001,"李xx",'M',25,90.3};struct student *p;p = &student1;printf("Numbers:%d\n",p->num);printf("Name:%s\n",p->name);printf("Sex:%c\n",p->sex);printf("Age:%d\n",p->age);printf("Score:%5.1f\n",p->score);
}

運(yùn)行結(jié)果

5、使用指針輸出數(shù)據(jù)元素

通過(guò)指針變量輸出數(shù)組的各元素值,程序運(yùn)行后,輸入10個(gè)數(shù)字后,可以看到輸出的數(shù)組元素值。?

#include<stdio.h>
int main()
{int *p,a[10],i;p=&a[0];printf("請(qǐng)輸入10個(gè)數(shù)字:\n");for(i=0;i<10;i++){scanf("%d",&a[i]);}printf("數(shù)組中的元素為:\n");for(i=0;i<10;i++){printf("%d",*(p+i));}printf("\n");
}

運(yùn)行結(jié)果

6、使用指針查找數(shù)組中的最大值和最小值。

輸入10整型數(shù),自動(dòng)查找數(shù)組中的最大值和最小值,并顯示在窗體上。

?

#include<stdio.h>
int max_min(int a[],int n,int *max,int *min);
int main()
{int i,a[10];int max,min;printf("Input 10 int eger numbers you want to operate:\n");for(i=0;i<10;i++){scanf("%d",&a[i]);}max_min(a,10,&max,&min);printf("\nThe maximun number is:%d\n",max);printf("The minimun number is :%d\n",min);
}
int max_min(int a[],int n,int *max,int *min)
{int *p;*max = *min = *a;for(p=a+1;p<a+n;p++)if(*p>*max){*max =*p;}else if(*p<*min){*min = *p;}return 0;}

運(yùn)行結(jié)果

7、使用指針連接兩個(gè)字符串

要求實(shí)現(xiàn)將兩個(gè)已知的字符串連接,放到另外一個(gè)字符串?dāng)?shù)組中,并將連接后的字符串輸出到屏幕上。?

#include<stdio.h>
#define N 20
char *MyStrcat(char *dstStr,char *srcStr)
{char *pStr = dstStr;while(*dstStr !='\0'){dstStr++;}for(;*srcStr!='\0';dstStr++,srcStr++){*dstStr = *srcStr;}*dstStr = '\0';return pStr;
}
int main()
{char first[2*N];char second[N];char *result = NULL;printf("輸入第一組:");gets(first);printf("輸入第二組:");gets(second);result = MyStrcat(first,second);printf("結(jié)果:%s\n",result);return 0;
}

運(yùn)行結(jié)果

8、用指針數(shù)組構(gòu)造字符串?dāng)?shù)組

要求實(shí)現(xiàn)輸入一個(gè)星期中對(duì)應(yīng)的第幾天,可顯示其英文寫法。如,輸入‘4’,則顯示星期四對(duì)應(yīng)的英文名。?

#include<stdio.h>
int main()
{char *Week[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};int i;printf("Please enter a number for week\n");scanf("%d",&i);printf("The week is :");printf("%s\n",Week[i-1]);return 0;
}

運(yùn)行結(jié)果

9、使用指針的指針輸出字符串

首先使用指針數(shù)組創(chuàng)建一個(gè)字符串?dāng)?shù)組,然后定義指向指針的指針,使其指向字符串?dāng)?shù)組,并使用其將數(shù)組中字符串輸出。?

#include<stdio.h>
int main()
{char *strings[]={"趙xx","錢xx","孫xx","李xx","周xx"};char **p,i;p=strings;printf("%s\n",strings[0]);for(i=0;i<5;i++){printf("%s\n",*(p+i));}return 0;
}

運(yùn)行結(jié)果

10、找出最高分

通過(guò)結(jié)構(gòu)體變量記錄學(xué)生成績(jī),比較得到記錄中的最高成績(jī),輸出該學(xué)生的信息。?

#include<stdio.h>
struct student
{int num;char name[20];float score;
};
int main()
{int i,m;float maxscore;struct student stu[5]={{101,"李明",89},{102,"苑達(dá)",95},{103,"孫佳",89},{104,"王子川",85},{105,"劉春月",75}, };m=0;maxscore = stu[0].score;for(i=1;i<5;i++){if(stu[i].score>maxscore){maxscore = stu[i].score;m=i;}} printf("最高分是:%5.1f\n",maxscore);printf("最高分學(xué)生的學(xué)號(hào)是:%d\n",stu[m].num);printf("最高分學(xué)生的姓名是:%s\n",stu[m].name);
}

運(yùn)行結(jié)果

?

http://www.risenshineclean.com/news/2135.html

相關(guān)文章:

  • 用vue.js做網(wǎng)站視頻推廣
  • 全球最好的云服務(wù)器搜索引擎優(yōu)化的目的是對(duì)用戶友好
  • 廣州做網(wǎng)站多少錢西安百度seo推廣電話
  • 做網(wǎng)站網(wǎng)頁(yè)的工作怎么樣自制網(wǎng)站
  • 論壇網(wǎng)站地圖怎么做免費(fèi)seo工具
  • 免費(fèi)建立網(wǎng)站的軟件任務(wù)推廣引流平臺(tái)
  • 四川建設(shè)網(wǎng)站電子招標(biāo)網(wǎng)站建設(shè)策劃方案
  • dedecms做地方網(wǎng)站百度推廣電話是多少
  • 深圳建工建設(shè)集團(tuán)有限公司網(wǎng)站seo站群軟件
  • 視頻手機(jī)網(wǎng)站開發(fā)廣告營(yíng)銷是做什么的
  • 如何做自己的網(wǎng)站后臺(tái)網(wǎng)絡(luò)營(yíng)銷的方式與手段
  • 潘家園網(wǎng)站建設(shè)公司亞馬遜查關(guān)鍵詞排名工具
  • 桂林駿程網(wǎng)站建設(shè)seo優(yōu)化流程
  • 哪個(gè)網(wǎng)站財(cái)經(jīng)做的最好寧波seo資源
  • 移動(dòng)網(wǎng)站開發(fā)百度百科常州seo收費(fèi)
  • 2017做網(wǎng)站賺錢短視頻平臺(tái)推廣方案
  • 重慶seo網(wǎng)站建設(shè)百度站長(zhǎng)鏈接提交
  • 手機(jī)有軟件做ppt下載網(wǎng)站王通seo教程
  • 國(guó)內(nèi)做日化官方網(wǎng)站怎么推廣軟件
  • 網(wǎng)站開發(fā)自學(xué)還是培訓(xùn)市場(chǎng)營(yíng)銷計(jì)劃
  • 網(wǎng)站開發(fā)會(huì)什么做網(wǎng)絡(luò)營(yíng)銷推廣
  • sfda的網(wǎng)站的建設(shè)特點(diǎn)免費(fèi)推廣的網(wǎng)站平臺(tái)
  • 個(gè)人網(wǎng)站整站源碼下載阜新網(wǎng)絡(luò)推廣
  • 網(wǎng)站制作與維護(hù)公司seo營(yíng)銷名詞解釋
  • 哪個(gè)網(wǎng)站做演唱會(huì)門票網(wǎng)絡(luò)推廣是做什么工作
  • 如何將項(xiàng)目發(fā)布到網(wǎng)上優(yōu)化關(guān)鍵詞首頁(yè)排行榜
  • 動(dòng)態(tài)網(wǎng)站沒有數(shù)據(jù)庫(kù)怎么做百度推廣代運(yùn)營(yíng)公司
  • 做日本暖暖小視頻網(wǎng)站seo服務(wù)內(nèi)容
  • 《網(wǎng)頁(yè)設(shè)計(jì)與網(wǎng)站建設(shè)》大作業(yè)要求關(guān)鍵詞愛站網(wǎng)關(guān)鍵詞挖掘工具
  • 想建立什么網(wǎng)站嗎關(guān)鍵詞調(diào)詞平臺(tái)哪個(gè)好