C语言 · 字符串输入输出函数

算法提高 3-2字符串输入输出函数  
时间限制:1.0s   内存限制:512.0MB
    
描述
  编写函数GetReal和GetString,在main函数中分别调用这两个函数。在读入一个实数和一个字符串后,将读入的结果依次用printf输出。
  两次输入前要输出的提示信息分别是"please input a number:\n”和"please input a string:\n"
样例输入
9.56
hello
样例输出
please input a number:
please input a string:
9.56
hello
 
 1 #include<stdio.h>
 2 void GetReal(double a){
 3     printf("%.2f\n",a);
 4 }
 5 void GetString(char b[]){
 6     printf("%s\n",b);
 7 }
 8 main(){
 9     double a;
10     char b[100];
11     scanf("%lf",&a);
12     scanf("%s",&b);
13     printf("please input a number:\n");
14     printf("please input a string:\n");
15     GetReal(a);
16     GetString(b);
17 }

 

posted @ 2017-03-13 00:22  人间烟火地三鲜  阅读(605)  评论(0)    收藏  举报