本週總結

本週總結
本週一開始學習了指針的定義,指針的類型,指針的實質是變量。(http://blog.csdn.net/qq_35576100/article/details/52153603)
本週二學習的是指針與一維數組的簡單交集,二維數組也是相對與一維數組多個集合在一塊的行數組。(http://blog.csdn.net/qq_35576100/article/details/52163753)
本週三學習了函數指針,函數指針的三部曲:複製函數名;摳掉函數名換成(*p)(xx);之後再調用函數指針傳入參數。 (http://blog.csdn.net/qq_35576100/article/details/52174964)
本週四學習的是字符串的定義,字符串的多種定義方式,以及字符串的打印是直接打印函數地址就能直接打印出字符串。         (http://blog.csdn.net/qq_35576100/article/details/52184171)
#include<stdio.h>
#include<Windows.h>
/*逐一打印字符*/
void main(){
	char str[] ={"I love U"};
	char *p = str;
	while(*p){
		printf("%c",*p);
		Sleep(1000);
		p++;
	}
	getchar();
	return;
}
輸入字符串,用除api的方式進行判斷
#include<stdio.h>
int fun(char *p,char *p1,int a){
	for(int i = 0;i<a;i++){
		if(*(p+i)!=*(p1+i)){
			return -1;		
		}
	}
	return 0;
}

void main(){
	printf("請輸入兩個字符串分別回車:");
	char ch[1000] = "0";
	char *p = ch;
	char ch1[1000] = "0";
	char *p1 = ch1;
	scanf("%s",ch);
	scanf("%s",ch1);
	if(sizeof(ch)/sizeof(char)!=sizeof(ch1)/sizeof(char)){
		printf("$ -1 $");
	}else
		printf("$ %d $",fun(p,p1,sizeof(ch1)/sizeof(char)));
	getchar();
}
<span style="white-space:pre">						</span>//矩陣對角線之和
#include<stdio.h>
int fun(int (*p)[3]){
	int S = 0;
	for(int i = 0;i<3;i++){
		S+=*(*(p+i)+i);
	}
	return S;
}

void main(){
	int a[][3] ={{1,2,3},{4,5,6},{7,8,9}};
	printf("矩陣對角線之和爲%d",fun(a));
	getchar();
	return;
}
#include <stdio.h>
                   /*打印從大到小的三個數*/
int main()
{
	int a,b,c,t;
	scanf("%d %d %d",&a,&b,&c);
	if ( a < b )
	{
		t = a;
		a = b;
		b = t;
	}
	if( a < c )
	{
		t = a;
		a = c;
		c = t;
	}
	if( b < c )
	{
		t = b;
		b = c;
		c = t; 
	}
	printf("%d %d %d",a,b,c);
	return 0;
}




發佈了50 篇原創文章 · 獲贊 39 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章