Advertisement
xlujiax

Lab1_2013

Aug 31st, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.72 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. /*
  8.  * File:   main.cpp
  9.  * Author: Renzo C
  10.  * scanf(%*d) Salta todos los espacios
  11.  * Created on 8 de agosto de 2016, 04:14 PM
  12.  */
  13.  
  14. #include <cstdlib>
  15. #include <cstdio>
  16.  
  17.  
  18. int main(int argc, char** argv) {
  19.     double precio;
  20.     int precio2;
  21.     int fin;
  22.     char finNum;
  23.     while (1) {
  24.         char c;
  25.         while (1) { //Lee el codigo de la cuenta hasta encontrar un salto de linea
  26.             scanf("%c",&c);
  27.             if (c == ' ') break;
  28.             putchar(c);
  29.         }
  30.         putchar('\n');
  31.         scanf("%*d");         //Salta todos los espacios
  32.         //printf("\n");
  33.         while (1) { //Lee el nombre de la cuenta hasta encontrar un salto de linea
  34.             scanf("%c",&c);        
  35.             if (c == ' ') break;
  36.             putchar(c);
  37.         }
  38.         putchar('\n');
  39.  
  40.         scanf("%lf", &precio);
  41.         printf("%-10.2lf\n", precio);
  42.         //scanf("%*d");
  43.  
  44.         while (1){  //Leera hasta no encontrar espacios
  45.             c = getchar();
  46.             if (c != ' ') break;
  47.         }
  48.        
  49.         while (1) {            
  50.             if (c<='9'&& c>='0') {
  51.                 putchar(c);
  52.                 while (1) { //Leer la fecha de la cuenta                    
  53.                     c = getchar();
  54.                     if (c == ' ') break;
  55.                     putchar(c);
  56.                 }
  57.             } else
  58.                 break;
  59.            
  60.             while (1) {
  61.                 scanf("%*d");
  62.                 putchar('\n');
  63.                 c = getchar();
  64.                 if (c != 'D' && c != 'R') {
  65.                     break;
  66.                 }
  67.                 putchar(c);
  68.                 while (fin = scanf("%d%c", &precio2,&finNum)) {
  69.                     if (fin == EOF) break;
  70.                    
  71.                     if (finNum != '/')
  72.                         printf("%10d", precio2);
  73.                     else{
  74.                         printf("\n");
  75.                         break;
  76.                     }                    
  77.                 }
  78.                 if (finNum == '/'){
  79.                     if (precio2<10)
  80.                         printf("0%d/",precio2);
  81.                     else
  82.                         printf("%d/",precio2);
  83.                     c = getchar();
  84.                     break;
  85.                 }
  86.                 if (finNum == '\n'){      
  87.                     printf("\n");
  88.                     break;
  89.                 }                
  90.             }
  91.             if (fin == EOF) break;
  92.         }
  93.         if (fin == EOF) break;
  94.     }
  95.     return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement