【807】
每天写点入门题,保持手感~
Garybr0
网络安全爱好者
展开
-
【807】简单处理学生成绩
#include<stdio.h>#define N 10struct student { char stuNum[20]; int math; int c;};void input(struct student *p,int n){ int i; for(i=0;i<n;i++){ printf("plesae input the %d stuNun:",i+1); scanf("%s",p[i].stuNum); printf("Please input原创 2021-12-17 22:56:15 · 183 阅读 · 0 评论 -
【807】矩阵周长元素之和
#include<stdio.h>#define M 4#define N 5int fun(int a[M][N]){ int sum=0,i,j; for(i=0;i<M;i++) { for(j=0;j<N;j++) { if(i==0||i==M-1) sum+=a[i][j]; else if(j==0||j==N-1) sum+=a[i][j]; } } return sum;}int main(){ in原创 2021-12-17 22:38:44 · 185 阅读 · 0 评论 -
【807】判断一天是一年中的第几天(包括闰年)
#include<stdio.h>struct Date{ int year; int month; int day;};int days(int year,int month,int day);int main(){ struct Date p; scanf("%d,%d,%d",&p.year,&p.month,&p.day); days(p.year,p.month,p.day); return 0;}int days(int year原创 2021-12-15 15:40:16 · 569 阅读 · 0 评论 -
【807】加减乘 指针
#include<stdio.h>int sum(int a,int b);int minus(int a,int b);int mul(int a,int b);int main(){ int result; int (*p)(int a,int b); int a=3,b=4,n; printf("please choose 1,2or3\n"); scanf("%d",&n); if(n==1) p=sum; if(n==2) p=minus; i原创 2021-12-15 14:55:59 · 720 阅读 · 1 评论 -
【807】指向函数的指针 求两数之和
#include<stdio.h>int sum(int a,int b);int main(){ int result; int (*p)(int a,int b)=sum; result=(*p)(1,3); printf("%d",result); return 0;} int sum(int a,int b){ return a+b;}原创 2021-12-15 14:43:14 · 1299 阅读 · 0 评论 -
【807】将一个字符数组中的字符串复制到另一个字符数组中
#include<stdio.h>char *strcopy_(char *str1,char *str2);int main(){ char str1[30],str2[30],*str; gets(str1); gets(str2); str=strcopy_(str1,str2); printf("string is :%s\n",str); return 0;}char *strcopy_(char *str1,char *str2){ int i; for(原创 2021-12-15 14:28:43 · 3244 阅读 · 0 评论 -
【807】指针输出数组元素
#include<stdio.h>int main(){ int a[5],i,*p; p=a; printf("please input 5 numbers:\n"); for(i=0;i<5;i++) { scanf("%d",p++); } p=a; for(i=0;i<5;i++) { printf("%d,",*(p++)); } return 0;}原创 2021-12-15 14:17:04 · 510 阅读 · 0 评论 -
【807】去除字符串中的数字
#include<stdio.h>int main(){ char *str1,*str2; char string[100]; gets(string); for(str1=string,str2=str1;*str1!='\0';) { if(*str1>='0'&&*str1<='9'){ str1++; } else { *str2=*str1; str1++; str2++; } } *str2=原创 2021-12-15 14:12:14 · 333 阅读 · 0 评论 -
蛇形方阵 三角形周长 11.2
#include<stdio.h>int a[100][100];int main(){ int n,i,j,sum=1; scanf("%d",&n); a[1][1]=1; for(i=1,j=1;sum<n*n;) //此处sum必须严格小于n^2 否则循环无法结束 { while(++j<=n && !a[i][j])a[i][j]=++sum;--j; while(++i<=n && !a[i][j])原创 2021-11-02 22:24:53 · 82 阅读 · 0 评论