zoukankan      html  css  js  c++  java
  • ‘(’向后紧跟,‘)’、‘,’、‘;’向前紧跟,紧跟处不留空格

    ‘(’向后紧跟,‘)’、‘,’、‘;’向前紧跟,紧跟处不留空格。

     1 #include <iostream>
     2 #include<stdio.h>
     3 #define size 3
     4 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
     5 
     6 
     7 using namespace std;
     8 //定义book结构类型
     9 struct book
    10 {
    11     char   title[20];
    12     char   author[15];
    13     int    pages;
    14     float  price;
    15 };
    16 //book结构的输入函数
    17 input_book(book& bk,char *name)
    18 {
    19     cout<<name<<":"<<endl;
    20     cout<<"title:";
    21     cin>>bk.title;
    22     cout<<"author:";
    23     cin>>bk.author;
    24     cout<<"pages:";
    25     cin>>bk.pages;
    26     cout<<"price:";
    27     cin>>bk.price;
    28 }
    29 //book结构的输出函数
    30 output_book(book& bk,char *name)
    31 {
    32     cout<<name<<":  ";
    33     cout<<bk.title<<" ";
    34     cout<<bk.author<<" ";
    35     cout<<bk.pages<<" ";
    36     cout<<bk.price<<endl;
    37 }
    38 
    39 int main(int argc, char** argv) {
    40         //声明变量和结构数组
    41     int i;
    42     char str[20];
    43     book bk[size];
    44 
    45     //输入结构数组
    46     for(i=0;i<size;i++) {
    47         sprintf(str,"bk[%d]",i+1);
    48         input_book(bk[i],str);
    49     }
    50 
    51     //显示结构数组
    52     for(i=0;i<size;i++) {
    53         sprintf(str,"bk[%d]",i+1);
    54         output_book(bk[i],str);
    55     }
    56     return 0;
    57     
    58 }
  • 相关阅读:
    lightoj 1027 简单概率dp
    zoj 3329 One Person Game 概率dp
    光速输入法
    百度卫士+7654联盟
    MyCCL复合特征码定位系统3.0 build 23 中文绿色版
    右键管家MenuMgr-1.2单文件
    影子卫士中文注册版+系统保护的尚方宝剑、、
    Easyspy网络检测系统
    百度杀毒+7654联盟
    QQ浏览器+7654联盟
  • 原文地址:https://www.cnblogs.com/borter/p/9413177.html
Copyright © 2011-2022 走看看