虫虫首页| 资源下载| 资源专辑| 精品软件
登录| 注册

scanf

scanf()是C语言中的一个输入函数。与printf函数一样,都被声明在头文件stdio.h里,因此在使用scanf函数时要加上#include<stdio.h>。(在有一些实现中,printf函数与scanf函数在使用时可以不使用预编译命令)它是格式输入函数,即按用户指定的格式从键盘上把数据输入到指定的变量之中。
  • 学会对文件的记录锁定

    学会对文件的记录锁定,及解锁。#include <stdio.h> #include <unistd.h> #include <fcntl.h> int main() { int fd int i struct { char name[20] uint ID int age } myrec fd =open("name", O_RDWR|O_CREAT, 0755) if (fd == -1) return -1 printf("Input your name:") scanf("%s", myrec.name) printf("Inpute your ID :") scanf("%d", &myrec.ID) printf("Input your age :") scanf("%d", &myrec.age) lseek(fd, 0,SEEK_END) lockf(fd, 1, 0) write(fd, (void *)&myrec, sizeof(myrec)) lockf(fd, 0 ,0) return 0 } 执行命令cc lock.c –o lock.out Chmod +x lock.out ./lock.out

    标签: 记录

    上传时间: 2016-01-04

    上传用户:亚亚娟娟123

  • Status CreateSMatrix(RLSMatrix &M) { // 创建稀疏矩阵M int i Triple T Status k printf("请输入矩阵的行

    Status CreateSMatrix(RLSMatrix &M) { // 创建稀疏矩阵M int i Triple T Status k printf("请输入矩阵的行数,列数,非零元素数:") scanf("%d,%d,%d",&M.mu,&M.nu,&M.tu) M.data[0].i=0 // 为以下比较做准备 for(i=1 i<=M.tu i++) { do {

    标签: Status CreateSMatrix RLSMatrix Triple

    上传时间: 2013-12-22

    上传用户:shanml

  • C语言的名里使用方法

    C语言的名里使用方法,包括输入输出函数,scanf,printf,define,还有ASCII码表

    标签: C语言

    上传时间: 2014-01-04

    上传用户:

  • S3C2410开发实验源代码及实验指导;内容包括: LED_ON LED_ON_C IO_ports arm-linux-ld memory_controller Nand Flash contro

    S3C2410开发实验源代码及实验指导;内容包括: LED_ON LED_ON_C IO_ports arm-linux-ld memory_controller Nand Flash controller uart printf,scanf interrupt controller timer mmu clock vivi等; 主要讲述了单片机s3c2410的使用。

    标签: memory_controller arm-linux-ld IO_ports LED_ON_C

    上传时间: 2013-12-21

    上传用户:851197153

  • printf(" 请输入%d个课程的代表值(<%d个字符): " ,(*G).vexnum,MAX_NAME) for(i=0 i<(*G).vexnum ++i)

    printf(" 请输入%d个课程的代表值(<%d个字符):\n" ,(*G).vexnum,MAX_NAME) for(i=0 i<(*G).vexnum ++i) /* 构造顶点向量 */ { scanf(" %s" ,(*G).vertices[i].data) (*G).vertices[i].firstarc=NULL } printf(" 请输入%d个课程的学分值(<%d个字符):\n" ,(*G).vexnum,MAX_NAME) for(i=0 i<(*G).vexnum ++i) /* 构造顶点向量 */ {scanf(" %s" ,(*G).verticestwo[i].data) } printf(&quo

    标签: vexnum quot MAX_NAME printf

    上传时间: 2016-08-15

    上传用户:Avoid98

  • 成績顯示三個部份abc #include<stdio.h> #include<stdlib.h> int main(void) { float gread

    成績顯示三個部份abc #include<stdio.h> #include<stdlib.h> int main(void) { float gread printf("請輸入分數\n") scanf("%f",&gread) if(gread>=80&&gread<=100) printf("成績為A\n") else if(gread>=60&&gread<=79) { printf("成績為B\n") } else if(gread>=0&&gread<60) { printf("成績為C\n") } else { printf("分數輸入錯誤\n") } system("pause") return 0 }

    标签: include stdlib float gread

    上传时间: 2014-01-15

    上传用户:waizhang

  • 河內塔問題 #include<stdio.h> #include<stdlib.h> int fun_a(int) void fun_b(int,int,int,in

    河內塔問題 #include<stdio.h> #include<stdlib.h> int fun_a(int) void fun_b(int,int,int,int) int main(void) { int n int option printf("題目二:河內塔問題\n") printf("請輸入要搬移的圓盤數目\n") scanf("%d",&n) printf("最少搬移的次數為%d次\n",fun_a(n)) printf("是否顯示移動過程? 是請輸入1,否則輸入0\n") scanf("%d",&option) if(option==1) { fun_b(n,1,2,3) } system("pause") return 0 } int fun_a(int n) { int sum1=2,sum2=0,i for(i=n i>1 i--) { sum1=sum1*2 } sum2=sum1-1 return sum2 } void fun_b(int n,int left,int mid,int right) { if(n==1) printf("把第%d個盤子從第%d座塔移動到第%d座塔\n",n,left,right) else { fun_b(n-1,left,right,mid) printf("把第%d個盤子從第%d座塔移動到第%d座塔\n",n,left,right) fun_b(n-1,mid,left,right) } }

    标签: int include stdlib fun_a

    上传时间: 2016-12-08

    上传用户:努力努力再努力

  • 函数分库函数和用户自定义函数两类: 库函数(又称系统函数)是高级语言软家中提供基础功能的函数。库函数文件以h为文件后缀

    函数分库函数和用户自定义函数两类: 库函数(又称系统函数)是高级语言软家中提供基础功能的函数。库函数文件以h为文件后缀,如C语言的stdio.h文件包括了printf(), scanf (),open(),close()。C语言中主函数要使用某库函数:#include<库函数文件名>

    标签: 函数 库函数

    上传时间: 2014-01-04

    上传用户:sy_jiadeyi

  • ①把settle定义成char型变量 ②settle=(settle>= A && settle <= B ) 写错了

    ①把settle定义成char型变量 ②settle=(settle>= A && settle <= B ) 写错了,改成(settle>= A && settle <= Z ) ③scanf函数后面加一句getchar()用来吸收回车键

    标签: settle char gt lt

    上传时间: 2017-04-21

    上传用户:moshushi0009

  • 两个链表的交集

    两个链表的交集 #include<stdio.h> #include<stdlib.h> typedef struct Node{   int data;   struct  Node *next; }Node; void initpointer(struct Node *p){   p=NULL; } int  printlist(struct Node* head){   int flag=1;   head=head->next;   /*   因为标记1的地方你用了头结点,所以第一个数据域无效,应该从下一个头元结点开始   */   if(head==NULL)     printf("NULL\n");   else   {     while(head!=NULL)     {       if(flag==1)       {       printf("%d",head->data);       flag=0;       }       else       {         printf(" %d",head->data);       }       head=head->next;     }     printf("\n");   }   return 0; } struct Node *creatlist(struct Node *head) {      int n;    struct  Node *p1=(struct Node *)malloc(sizeof(struct Node));   p1->next=NULL; while(scanf("%d",&n),n!=-1) {   struct Node *pnode=(struct Node *)malloc(sizeof(struct Node));   pnode->next=NULL;      pnode->data=n;   if(head==NULL)     head=pnode;   p1->next=pnode;   p1=pnode; } return head; } struct Node *Intersect(struct Node *head1, struct Node *head2) { struct Node *p1=head1,*p2=head2;/*我这里没有用头指针和头结点,这里是首元结点head1里面就是第一个数据,一定要理解什么事头指针, 头结点,和首元结点 具体你一定要看这个博客:http://blog.sina.com.cn/s/blog_71e7e6fb0101lipz.html*/ struct Node *head,*p,*q; head = (struct Node *)malloc(sizeof(struct Node)); head->next = NULL; p = head; while( (p1!=NULL)&&(p2!=NULL) ) { if (p1->data == p2->data) { q = (struct Node *)malloc(sizeof(struct Node)); q->data = p1->data; q->next = NULL; p->next = q;//我可以认为你这里用了头结点,也就是说第一个数据域无效     **标记1** p = q; p1 = p1->next; p2 = p2->next; } else if (p1->data < p2->data) { p1 = p1->next; } else { p2 = p2->next; } } return head; } int main() {   struct Node *head=NULL,*headt=NULL,*t;   //initpointer(head);//这里的函数相当于head=NULL;  // initpointer(headt);//上面已经写了headt=NULL那么这里可以不用调用这个函数   head=creatlist(head);   headt=creatlist(headt);   t=Intersect(head,headt);   printlist(t); }

    标签: c语言编程

    上传时间: 2015-04-27

    上传用户:coco2017co