zoukankan      html  css  js  c++  java
  • uva 488

     1 /*
     2  * Author: Quickgrid ( Asif Ahmed )
     3  * Site: https://quickgrid.wordpress.com
     4  * Problem: UVA 488 ( Triangle Wave )
     5  */
     6 #include<stdio.h>
     7  
     8 /* For this problem amplitude does not exceed 9, so you can cheat <span class="wp-smiley wp-emoji wp-emoji-smile" title=":)">:)</span> */
     9 const char *a[] = {"", "1", "22", "333", "4444", "55555", "666666", "7777777", "88888888", "999999999"};
    10  
    11 int main(){
    12     register unsigned n, i, j, k;
    13     scanf("%u", &n);
    14  
    15     while(n--){
    16         unsigned amp, times;
    17         scanf("%u%u", &amp, &times);
    18  
    19         while(times--){
    20             for(i = 1; i < amp; ++i)
    21                 /* Just print the predefined strings */
    22                 printf("%s
    ", a[i]);
    23  
    24             for(k = i; k; --k)
    25                 printf("%s
    ", a[k]);
    26  
    27             if(times || n)
    28                 printf("
    ");
    29         }
    30     }
    31     return 0;
    32 }
    c
     1 #include <iostream>
     2 #include <cstring>
     3 #include <cstdio>
     4 using namespace std;
     5 
     6 const string a[] = {"", "1", "22", "333", "4444", "55555", "666666", "7777777", "88888888", "999999999"};
     7 
     8 int main()
     9 {
    10     register unsigned n, i, j, k;
    11     string output, total = "";
    12     scanf("%u", &n);
    13 
    14     while(n--)
    15     {
    16         unsigned amp, times;
    17         scanf("%u%u", &amp, &times);
    18         output = "";
    19        
    20         while(times--)
    21         {
    22             for(i=1; i<amp; ++i)
    23                 output += a[i] + "
    ";
    24             for(k=i; k; --k)
    25                 output += a[k] + "
    ";
    26             
    27             if(times || n)
    28                 output += "
    ";
    29         }
    30         total += output;
    31     }
    32 
    33     cout << total;
    34     return 0;
    35 }
    c++

    代码来源

  • 相关阅读:
    垃圾收集器与内存分配策略(二)之垃圾收集算法
    组合与继承
    垃圾收集器与内存分配策略(一)之对象存活判断
    虚拟机中对象的创建、内存布局、访问
    Java运行时数据区域划分
    Java操作excel表格
    位段
    sh -s用法
    ubutu14.04选中文本就会删除问题解决
    java容器-List
  • 原文地址:https://www.cnblogs.com/aze-003/p/5092864.html
Copyright © 2011-2022 走看看