随笔分类 -  C

摘要:#include<stdio.h>int main(){ int a=3,*p; p=&a; printf("a=%d,*p=%d\n",a,*p);//a=3,*p=3 *p=10; printf("a=%d,*p=%d\n",a,*p);//a=10,*p=10 printf("Enter a: 阅读全文
posted @ 2025-01-02 16:04 Grit_Doyle 阅读(13) 评论(0) 推荐(0)
摘要:#include<stdio.h>void month_day(int year,int yearday,int*pmonth,int *pday);int main(){ int day,month,year,yearday; printf("input year and yearday:"); 阅读全文
posted @ 2025-01-02 16:04 Grit_Doyle 阅读(15) 评论(0) 推荐(0)
摘要:#include<stdio.h>void bubble(int a[],int n);int main(){ int n,a[8]; int i; printf("Enter n (n<=8):"); scanf("%d",&n); printf("Enter a[%d]:",n); for(i= 阅读全文
posted @ 2025-01-02 16:04 Grit_Doyle 阅读(10) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int x=5342; int *p=NULL; p=&x; printf("If I know the name of variable,I can get it's value by name:%d\n",x); printf("If I 阅读全文
posted @ 2025-01-02 16:03 Grit_Doyle 阅读(62) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int x,y; int *px,*py; x=1;y=2; px=&x;py=&y; printf("x=%d,y=%d,px=%d,py=%d,*px=%d,*py=%d\n",x,y,px,py,*px,*py); px++;//等同于 阅读全文
posted @ 2025-01-02 16:03 Grit_Doyle 阅读(12) 评论(0) 推荐(0)
摘要:#include<stdio.h>int day_of_year(int year,int mouth,int day);int main(){ int year,mouth,day,date; printf("输入年月日:"); scanf("%d%d%d",&year,&mouth,&day); 阅读全文
posted @ 2025-01-02 16:02 Grit_Doyle 阅读(14) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int i,index,n; int a[10]; printf("Enter n:"); scanf("%d",&n); printf("Enter %d integers:",n); for(i=0;i<n;i++){ scanf("%d 阅读全文
posted @ 2025-01-02 16:02 Grit_Doyle 阅读(24) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int i,flag,x; int a[5]; printf("Enter 5 integers:"); for(i=0;i<5;i++){ scanf("%d",&a[i]); } printf("Enter x:"); scanf("%d 阅读全文
posted @ 2025-01-02 16:01 Grit_Doyle 阅读(16) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int i,index,k,n,temp; int a[10]; printf("Enter n:"); scanf("%d",&n); printf("Enter %d integers:",n); for(i=0;i<n;i++){ sc 阅读全文
posted @ 2025-01-02 16:01 Grit_Doyle 阅读(14) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int i,response; int count[9]; for(i=1;i<=8;i++){ count[i]=0; } for(i=1;i<=10;i++){ printf("Emter your response:"); scanf( 阅读全文
posted @ 2025-01-02 16:00 Grit_Doyle 阅读(19) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int count,i; char str[80]; printf("Enter a string:"); i=0; while((str[i]=getchar())!='\n'){ i++; } str[i]='\0'; count=0; 阅读全文
posted @ 2025-01-02 16:00 Grit_Doyle 阅读(21) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int i,number; char str[10]; printf("Enter a string:"); i=0; while((str[i]=getchar())!='\n'){ i++; } str[i]='\0'; number=0 阅读全文
posted @ 2025-01-02 15:59 Grit_Doyle 阅读(15) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ //输出斐波那契数列 int i; int fib[10]={1,1}; for(i=2;i<10;i++){ fib[i]=fib[i-1]+fib[i-2]; } for(i=0;i<10;i++){ printf("%6d",fib[i 阅读全文
posted @ 2025-01-02 15:59 Grit_Doyle 阅读(11) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ //输入10个数。输出所有大于平均数的值 int i; double average,sum; int a[10]; printf("Enter 10 integers:"); sum=0; for(i=0;i<10;i++){ scanf( 阅读全文
posted @ 2025-01-02 15:59 Grit_Doyle 阅读(23) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int i,index,n; int a[10]; printf("Enter n:"); scanf("%d",&n); printf("Enter %d integers:",n); for(i=0;i<n;i++){ scanf("%d 阅读全文
posted @ 2025-01-02 15:58 Grit_Doyle 阅读(18) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int col,i,j,row; int a[3][2]; printf("Enter 6 integers:\n"); for(i=0;i<3;i++){ for(j=0;j<2;j++){ scanf("%d",&a[i][j]); } 阅读全文
posted @ 2025-01-02 15:58 Grit_Doyle 阅读(15) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int i,k; char line[80]; printf("Enter a string:"); k=0; while((line[k]=getchar())!='\n'){ k++; } line[k]='\0'; i=0; k=k-1 阅读全文
posted @ 2025-01-02 15:58 Grit_Doyle 阅读(12) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int i,j,n,temp; int a[6][6]; printf("Enter n:"); scanf("%d",&n); for(i=0;i<n;i++){ for(j=0;j<n;j++){ a[i][j]=i*n+j+1; } } 阅读全文
posted @ 2025-01-02 15:57 Grit_Doyle 阅读(11) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int i,j; int a[3][2]; for(i=0;i<3;i++){ for(j=0;j<2;j++){ a[i][j]=i+j; } } for(i=0;i<3;i++){ for(j=0;j<2;j++){ printf("%2 阅读全文
posted @ 2025-01-02 15:57 Grit_Doyle 阅读(14) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<math.h>int reverse(int number);int main(){ int i; printf("输入一位整数:"); scanf("%d",&i); printf("它的逆序数是:%d",reverse(i)); return 阅读全文
posted @ 2025-01-02 15:54 Grit_Doyle 阅读(34) 评论(0) 推荐(0)