C语言问题

编写几个函数:(1)输入10个职工的姓名和职工号;(2)按职工号由小到大顺序排序,姓名顺序也随之调整;(3)要求输入一个职工号,找出该职工的姓名,从主函数输入要查找的职工号,输出该职工姓名。谁会写这个程序啊,用c语言写
默认分类 | 2011-05-29 22:10 | 阅读 1658 次 | 评论 6 条

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( &amp;b ); printf("%d %d\n",a.num,b.num); }
默认分类 | 2011-05-27 12:07 | 阅读 676 次 | 评论 0 条

c语言

#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);}
默认分类 | 2011-05-27 12:07 | 阅读 667 次 | 评论 1 条

c语言

#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=&amp;a; func(p); printf("%d,%c\n",a.x,a.ch);}
默认分类 | 2011-05-27 12:06 | 阅读 775 次 | 评论 1 条

switch的用法

#include <stdio.h>void main(){ int x,y; scanf("%d",&amp;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解...
默认分类 | 2011-05-16 22:46 | 阅读 807 次 | 评论 1 条

天气变化的真快

今天下雨了
默认分类 | 2011-05-14 12:37 | 阅读 717 次 | 评论 0 条

逆序输出字符串

#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);}
默认分类 | 2011-05-13 12:50 | 阅读 784 次 | 评论 0 条

求学生的成绩

#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...
默认分类 | 2011-05-13 12:49 | 阅读 900 次 | 评论 0 条

统计问题

#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...
默认分类 | 2011-05-13 12:40 | 阅读 731 次 | 评论 0 条

求e的值

#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);}
默认分类 | 2011-05-09 13:45 | 阅读 699 次 | 评论 1 条

求PI的值

#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;}
默认分类 | 2011-05-09 13:45 | 阅读 612 次 | 评论 1 条

字符逆序存放

#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);}
默认分类 | 2011-05-09 13:42 | 阅读 1440 次 | 评论 9 条
文章分类
文章归档