本周总结

本周总结
本周一开始学习了指针的定义,指针的类型,指针的实质是变量。(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万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章