编写几个函数:(1)输入10个职工的姓名和职工号;(2)按职工号由小到大顺序排序,姓名顺序也随之调整;(3)要求输入一个职工号,找出该职工的姓名,从主函数输入要查找的职工号,输出该职工姓名。谁会写这个程序啊,用c语言写
#include <stdio.h>struct stu{ char name[10]; int num;};void f( struct stu* c ){ struct stu b={ "LiSiGuo", 2042 }; *c = b;}void main(){ struct stu a={"YangSan",2041}, b={"WangYin",2043}; f( &b ); printf("%d %d\n",a.num,b.num); }
#include <stdio.h>struct stu{int num;char name[10];int age;};void fun(struct stu *p){printf("%s\n",);}void main(){ students[3]={{100,"Zhang",20},{1002,"Wang",19},{1003,"Zhao",18}}; fun(students);}
#include <stdio.h>struct stru{int x;char ch;};void func(struct stru *b){b->x=200;b->ch='y';}void main(){ struct stru a={10,'x'},*p=&a; func(p); printf("%d,%c\n",a.x,a.ch);}
#include <stdio.h>void main(){ int x,y; scanf("%d",&x) if(x>0) { switch(x/10) case 0:y=-10;break; case 1:y=3;break; case 2:y=10;break; default:y=20; printf("%d%d\n",x,y); } else printf("x=%d不在范围内");}题目: { -10,0<x<10 { 3,10<=x<20 y= { (switch解...
今天下雨了
#include <stdio.h>void fac(char ch=getchar()){ if(ch!='\n'){ fac(ch=getchar()); printf("%c",ch); }}void main(){ char ch; printf("输入一行字符串\n"); fac(ch=getchar()); printf("%c\n",ch);}
#include "stdio.h"#include "stdlib.h"#define N 3struct student{ char num[6]; char name[10]; int score[3]; float average;}stu[N];int main(void){ void print(struct student stu[10]); int i,j; for(i=0;i<N;i++) { printf("in...
#include<stdio.h> void main() { printf("input a sentence \n"); char a[80],*p; int i=0,lowercase=0,uppercase=0,space=0,tab=0,enter=0; printf("ps: input ctrl+z to end of the input and press enter to show the result\n"); printf("=====================================\n"); while(1) { if((a[i]=getcha...
#include <stdio.h>void main(){int n=1;float i=1,e=1;for(n=1;n<=50;n++){i=i*n;e=e+1/i;}printf("%f",e);}
#include <stdio.h>float getPI();void main(){ float PI= getPI(); printf("PI= %f\n",PI); }float getPI(){ float PI = 0.0; float x = 1.0; float y= 1.0; do { PI +=y; y *= x / (2 * x + 1); x += 1.0;} while (y > 0.000001);PI*=2; return PI;}
#include <stdio.h>#include <string.h >void fun(char str[]){ int i;for (i=strlen(str)-1;i>=0;i--)printf("%c", str[i]);printf("\n");}void main(){ char str[81];printf("input the string :\n");scanf("%s",str);fun(str);printf("%s\n",str);}