#include<stdio.h> #include<stdlib.h> #include<conio.h> #include<string.h> main(void) { char new_name[4], name[4]; int new_sn ,sn; Printf(" 【注册】\n\n"); Printf("请输入用户名(四位英文字母):"); scanf("%s", &new_name); Printf("请输入密码(六位数字):") ; scanf("%d" ,&new_sn); /*system("PAUSE");*/ system("CLS");/*清屏*/ /*system("PAUSE");*/ Printf(" 【登陆】\n\n"); Printf("输入用户名:"); scanf("%s" , &name); if(!strcmp(new_name,name)){Printf("输入用户名错误!"); }/*判断用户是否正确*/ Printf("输入密码:"); scanf("%d" , &sn); if(new_sn != sn){Printf("输入密码错误!"); }/*判断密码是否正确*/ system("CLS"); Printf("恭喜你,登陆成功!\n"); getchar(); return 0; }
标签: C语言
上传时间: 2015-12-30
上传用户:gjatd1987
一个STM8入门例子,初学者的福音,包含库2.1版本,不可错过哦
标签: STM8 DEMO
上传时间: 2016-04-08
上传用户:Sapphy
实验源代码 //Warshall.cpp #include<stdio.h> void warshall(int k,int n) { int i , j, t; int temp[20][20]; for(int a=0;a<k;a++) { Printf("请输入矩阵第%d 行元素:",a); for(int b=0;b<n;b++) { scanf ("%d",&temp[a][b]); } } for(i=0;i<k;i++){ for( j=0;j<k;j++){ if(temp[ j][i]==1) { for(t=0;t<n;t++) { temp[ j][t]=temp[i][t]||temp[ j][t]; } } } } Printf("可传递闭包关系矩阵是:\n"); for(i=0;i<k;i++) { for( j=0;j<n;j++) { Printf("%d", temp[i][ j]); } Printf("\n"); } } void main() { Printf("利用 Warshall 算法求二元关系的可传递闭包\n"); void warshall(int,int); int k , n; Printf("请输入矩阵的行数 i: "); scanf("%d",&k); 四川大学实验报告 Printf("请输入矩阵的列数 j: "); scanf("%d",&n); warshall(k,n); }
上传时间: 2016-06-27
上传用户:梁雪文以
#include <stdlib.h> #include<stdio.h> #include <malloc.h> #define stack_init_size 100 #define stackincrement 10 typedef struct sqstack { int *base; int *top; int stacksize; } sqstack; int StackInit(sqstack *s) { s->base=(int *)malloc(stack_init_size *sizeof(int)); if(!s->base) return 0; s->top=s->base; s->stacksize=stack_init_size; return 1; } int Push(sqstack *s,int e) { if(s->top-s->base>=s->stacksize) { s->base=(int *)realloc(s->base,(s->stacksize+stackincrement)*sizeof(int)); if(!s->base) return 0; s->top=s->base+s->stacksize; s->stacksize+=stackincrement; } *(s->top++)=e; return e; } int Pop(sqstack *s,int e) { if(s->top==s->base) return 0; e=*--s->top; return e; } int stackempty(sqstack *s) { if(s->top==s->base) { return 1; } else { return 0; } } int conversion(sqstack *s) { int n,e=0,flag=0; Printf("输入要转化的十进制数:\n"); scanf("%d",&n); Printf("要转化为多少进制:\n"); scanf("%d",&flag); Printf("将十进制数%d 转化为%d 进制是:\n",n,flag); while(n) { Push(s,n%flag); n=n/flag; } while(!stackempty(s)) { e=Pop(s,e); switch(e) { case 10: Printf("A"); break; case 11: Printf("B"); break; case 12: Printf("C"); break; case 13: Printf("D"); break; case 14: Printf("E"); break; case 15: Printf("F"); break; default: Printf("%d",e); } } Printf("\n"); return 0; } int main() { sqstack s; StackInit(&s); conversion(&s); return 0; }
上传时间: 2016-12-08
上传用户:爱你198
void DFS(MGraph G, int i) { int j; visited[i] = TRUE; Printf("%c ", G.vexs[i]); for (j=0; j<G.numVertexes; ++j) { if (G.arc[i][j]!=INFINITY && !visited[j]) DFS(G, j); } }
上传时间: 2016-12-28
上传用户:chenyameng
#include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define NULL 0 #define MaxSize 30 typedef struct athletestruct /*运动员*/ { char name[20]; int score; /*分数*/ int range; /**/ int item; /*项目*/ }ATH; typedef struct schoolstruct /*学校*/ { int count; /*编号*/ int serial; /**/ int menscore; /*男选手分数*/ int womenscore; /*女选手分数*/ int totalscore; /*总分*/ ATH athlete[MaxSize]; /**/ struct schoolstruct *next; }SCH; int nsc,msp,wsp; int ntsp; int i,j; int overgame; int serial,range; int n; SCH *head,*pfirst,*psecond; int *phead=NULL,*pafirst=NULL,*pasecond=NULL; void create(); void input () { char answer; head = (SCH *)malloc(sizeof(SCH)); /**/ head->next = NULL; pfirst = head; answer = 'y'; while ( answer == 'y' ) { Is_Game_DoMain: Printf("\nGET Top 5 when odd\nGET Top 3 when even"); Printf("\n输入运动项目序号 (x<=%d):",ntsp); scanf("%d",pafirst); overgame = *pafirst; if ( pafirst != phead ) { for ( pasecond = phead ; pasecond < pafirst ; pasecond ++ ) { if ( overgame == *pasecond ) { Printf("\n这个项目已经存在请选择其他的数字\n"); goto Is_Game_DoMain; } } } pafirst = pafirst + 1; if ( overgame > ntsp ) { Printf("\n项目不存在"); Printf("\n请重新输入"); goto Is_Game_DoMain; } switch ( overgame%2 ) { case 0: n = 3;break; case 1: n = 5;break; } for ( i = 1 ; i <= n ; i++ ) { Is_Serial_DoMain: Printf("\n输入序号 of the NO.%d (0<x<=%d): ",i,nsc); scanf("%d",&serial); if ( serial > nsc ) { Printf("\n超过学校数目,请重新输入"); goto Is_Serial_DoMain; } if ( head->next == NULL ) { create(); } psecond = head->next ; while ( psecond != NULL ) { if ( psecond->serial == serial ) { pfirst = psecond; pfirst->count = pfirst->count + 1; goto Store_Data; } else { psecond = psecond->next; } } create(); Store_Data: pfirst->athlete[pfirst->count].item = overgame; pfirst->athlete[pfirst->count].range = i; pfirst->serial = serial; Printf("Input name:) : "); scanf("%s",pfirst->athlete[pfirst->count].name); } Printf("\n继续输入运动项目(y&n)?"); answer = getchar(); Printf("\n"); } } void calculate() /**/ { pfirst = head->next; while ( pfirst->next != NULL ) { for (i=1;i<=pfirst->count;i++) { if ( pfirst->athlete[i].item % 2 == 0 ) { switch (pfirst->athlete[i].range) { case 1:pfirst->athlete[i].score = 5;break; case 2:pfirst->athlete[i].score = 3;break; case 3:pfirst->athlete[i].score = 2;break; } } else { switch (pfirst->athlete[i].range) { case 1:pfirst->athlete[i].score = 7;break; case 2:pfirst->athlete[i].score = 5;break; case 3:pfirst->athlete[i].score = 3;break; case 4:pfirst->athlete[i].score = 2;break; case 5:pfirst->athlete[i].score = 1;break; } } if ( pfirst->athlete[i].item <=msp ) { pfirst->menscore = pfirst->menscore + pfirst->athlete[i].score; } else { pfirst->womenscore = pfirst->womenscore + pfirst->athlete[i].score; } } pfirst->totalscore = pfirst->menscore + pfirst->womenscore; pfirst = pfirst->next; } } void output() { pfirst = head->next; psecond = head->next; while ( pfirst->next != NULL ) { // clrscr(); Printf("\n第%d号学校的结果成绩:",pfirst->serial); Printf("\n\n项目的数目\t学校的名字\t分数"); for (i=1;i<=ntsp;i++) { for (j=1;j<=pfirst->count;j++) { if ( pfirst->athlete[j].item == i ) { Printf("\n %d\t\t\t\t\t\t%s\n %d",i,pfirst->athlete[j].name,pfirst->athlete[j].score);break; } } } Printf("\n\n\n\t\t\t\t\t\t按任意建 进入下一页"); getchar(); pfirst = pfirst->next; } // clrscr(); Printf("\n运动会结果:\n\n学校编号\t男运动员成绩\t女运动员成绩\t总分"); pfirst = head->next; while ( pfirst->next != NULL ) { Printf("\n %d\t\t %d\t\t %d\t\t %d",pfirst->serial,pfirst->menscore,pfirst->womenscore,pfirst->totalscore); pfirst = pfirst->next; } Printf("\n\n\n\t\t\t\t\t\t\t按任意建结束"); getchar(); } void create() { pfirst = (struct schoolstruct *)malloc(sizeof(struct schoolstruct)); pfirst->next = head->next ; head->next = pfirst ; pfirst->count = 1; pfirst->menscore = 0; pfirst->womenscore = 0; pfirst->totalscore = 0; } void Save() {FILE *fp; if((fp = fopen("school.dat","wb"))==NULL) {Printf("can't open school.dat\n"); fclose(fp); return; } fwrite(pfirst,sizeof(SCH),10,fp); fclose(fp); Printf("文件已经成功保存\n"); } void main() { system("cls"); Printf("\n\t\t\t 运动会分数统计\n"); Printf("输入学校数目 (x>= 5):"); scanf("%d",&nsc); Printf("输入男选手的项目(x<=20):"); scanf("%d",&msp); Printf("输入女选手项目(<=20):"); scanf("%d",&wsp); ntsp = msp + wsp; phead = (int *)calloc(ntsp,sizeof(int)); pafirst = phead; pasecond = phead; input(); calculate(); output(); Save(); }
标签: 源代码
上传时间: 2016-12-28
上传用户:150501
#include "string.h" #include "ctype.h" #include "stdio.h" search(char pd[]) {FILE *fp; int time=0,i=0,j=0,add[80],k=0,m; char *ch, str[900]; m=strlen(pd); if((fp=fopen("haha.txt","r"))==NULL) { Printf("Cannot open this file\n"); exit(0); } for(;!feof(fp);i++) { str[i]=fgetc(fp); if(tolower(str[i])==tolower(pd[k])) {k++; if(k==m) if(!isalpha(i-m)&&!isalpha((str[i++]=fgetc(fp)))) { time++; add[j]=i-m+1; j++; k=0; } else k=0; } } if(time) { Printf("The time is:%d\n",time); Printf("The adders is:\n"); for(i=0;i
标签: 查询学会少年宫
上传时间: 2016-12-29
上传用户:767483511
#include "string.h" #include "ctype.h" #include "stdio.h" search(char pd[]) {FILE *fp; int time=0,i=0,j=0,add[80],k=0,m; char *ch, str[900]; m=strlen(pd); if((fp=fopen("haha.txt","r"))==NULL) { Printf("Cannot open this file\n"); exit(0); } for(;!feof(fp);i++) { str[i]=fgetc(fp); if(tolower(str[i])==tolower(pd[k])) {k++; if(k==m) if(!isalpha(i-m)&&!isalpha((str[i++]=fgetc(fp)))) { time++; add[j]=i-m+1; j++; k=0; } else k=0; } } if(time) { Printf("The time is:%d\n",time); Printf("The adders is:\n"); for(i=0;i<j;i++) Printf("%5d",add[i]); if(i%5==0) Printf("\n"); getch(); fclose(fp); } else Printf("Sorry!Cannot find the word(^_^)"); } main() { char pd[10],choose='y'; int flag=1; while(flag) {Printf("In put the word you want to seqarch:"); scanf("%s",pd); search(strlwr(pd)); Printf("\nWould you want to continue?(Y/N):"); getchar(); scanf("%c",&choose); if((tolower(choose))=='n') flag=0; else flag=1; } Printf("Thanks for your using!Bye-bye!\n"); getch(); }
标签: 学生专用
上传时间: 2016-12-29
上传用户:767483511
/*import java.util.Scanner; //主类 public class student122 { //主方法 public static void main(String[] args){ //定义7个元素的字符数组 String[] st = new String[7]; inputSt(st); //调用输入方法 calculateSt(st); //调用计算方法 outputSt(st); //调用输出方法 } //其他方法 //输入方法 private static void inputSt(String st[]){ System.out.println("输入学生的信息:"); System.out.println("学号 姓名 成绩1,2,3"); //创建键盘输入类 Scanner ss = new Scanner(System.in); for(int i=0; i<5; i++){ st[i] = ss.next(); //键盘输入1个字符串 } } //计算方法 private static void calculateSt(String[] st){ int sum = 0; //总分赋初值 int ave = 0; //平均分赋初值 for(int i=2;i<5;i++) { /计总分,字符变换成整数后进行计算 sum += Integer.parseInt(st[i]); } ave = sum/3; //计算平均分 //整数变换成字符后保存到数组里 st[5] = String.valueOf(sum); st[6] = String.valueOf(ave); } //输出方法 private static void outputSt(String[] st){ System.out.print("学号 姓名 "); //不换行 System.out.print("成绩1 成绩2 成绩3 "); System.out.println("总分 平均分");//换行 //输出学生信息 for(int i=0; i<7; i++){ //按格式输出,小于6个字符,补充空格 System.out.Printf("%6s", st[i]); } System.out.println(); //输出换行 } }*/ import java.util.Scanner; public class student122 { public static void main(String[] args) { // TODO 自动生成的方法存根 String[][] st = new String[3][8]; inputSt(st); calculateSt(st); outputSt(st); } //输入方法 private static void inputSt(String st[][]) { System.out.println("输入学生信息:"); System.out.println("班级 学号 姓名 成绩:数学 物理 化学"); //创建键盘输入类 Scanner ss = new Scanner(System.in); for(int j = 0; j < 3; j++) { for(int i = 0; i < 6; i++) { st[j][i] = ss.next(); } } } //输出方法 private static void outputSt(String st[][]) { System.out.println("序号 班级 学号 姓名 成绩:数学 物理 化学 总分 平均分"); //输出学生信息 for(int j = 0; j < 3; j++) { System.out.print(j+1 + ":"); for(int i = 0; i < 8; i++) { System.out.Printf("%6s", st[j][i]); } System.out.println(); } } //计算方法 private static void calculateSt(String[][] st) { int sum1 = 0; int sum2 = 0; int sum3 = 0; int ave1 = 0; int ave2 = 0; int ave3 = 0; for(int i = 3; i < 6; i++) { sum1 += Integer.parseInt(st[0][i]); } ave1 = sum1/3; for(int i = 3; i < 6; i++) { sum2 += Integer.parseInt(st[1][i]); } ave2 = sum2/3; for(int i = 3; i < 6; i++) { sum3 += Integer.parseInt(st[2][i]); } ave3 = sum3/3; st[0][6] = String.valueOf(sum1); st[1][6] = String.valueOf(sum2); st[2][6] = String.valueOf(sum3); st[0][7] = String.valueOf(ave1); st[1][7] = String.valueOf(ave2); st[2][7] = String.valueOf(ave3); } }
上传时间: 2017-03-17
上传用户:simple
1.Describe a Θ(n lg n)-time algorithm that, given a set S of n integers and another integer x, determines whether or not there exist two elements in S whose sum is exactly x. (Implement exercise 2.3-7.) #include<stdio.h> #include<stdlib.h> void merge(int arr[],int low,int mid,int high){ int i,k; int *tmp=(int*)malloc((high-low+1)*sizeof(int)); int left_low=low; int left_high=mid; int right_low=mid+1; int right_high=high; for(k=0;left_low<=left_high&&right_low<=right_high;k++) { if(arr[left_low]<=arr[right_low]){ tmp[k]=arr[left_low++]; } else{ tmp[k]=arr[right_low++]; } } if(left_low<=left_high){ for(i=left_low;i<=left_high;i++){ tmp[k++]=arr[i]; } } if(right_low<=right_high){ for(i=right_low;i<=right_high;i++) tmp[k++]=arr[i]; } for(i=0;i<high-low+1;i++) arr[low+i]=tmp[i]; } void merge_sort(int a[],int p,int r){ int q; if(p<r){ q=(p+r)/2; merge_sort(a,p,q); merge_sort(a,q+1,r); merge(a,p,q,r); } } int main(){ int a[8]={3,5,8,6,4,1,1}; int i,j; int x=10; merge_sort(a,0,6); Printf("after Merging-Sort:\n"); for(i=0;i<7;i++){ Printf("%d",a[i]); } Printf("\n"); i=0;j=6; do{ if(a[i]+a[j]==x){ Printf("exist"); break; } if(a[i]+a[j]>x) j--; if(a[i]+a[j]<x) i++; }while(i<=j); if(i>j) Printf("not exist"); system("pause"); return 0; }
上传时间: 2017-04-01
上传用户:糖儿水嘻嘻