2013 C Language Program design competition (junior group), Jiangxi University of Technology

Source: Internet
Author: User

ACM ICPC World FINAL

Solution: sort Everybody knows, go to heavy words, beginners with array is good

#include <algorithm> #include <iostream>using namespace std;int main () {    int a,b,c[100],i,d[31];    cin>>a;    While (a>0)    {        cin>>b;        For (i=0;i<31;i++)            d[i]=0;        For (i=0;i<b;i++)        {            cin>>c[i];        }         For (i=0;i<b;i++)         {             d[c[i]]++;         }         For (i=0;i<31;i++)         {             if (d[i]!=0)                cout<<i<< "";         }         cout<<endl;         a--;}    }
Wood

Solution: to find the law, the front n lines are in the middle output *, the n+1 line all output *, the next with the middle as a symmetric relationship, to expand on both sides

 #include <bits/stdc++.h>using namespace Std;int main () {int n;            While (cin>>n&&n) {for (int. i=1;i<=2*n+1;i++) {for (int j=1;j<=2*n+1;j++)                {if (j==n+1) {cout<< "*";                } else if (i==n+1) {cout<< "*";                    } else if (i>n+1) {int pos=i-(n+1);                    cout<<pos<<endl; If (n+1-pos==j| |                    N+1+pos==j) {cout<< "*";                } else {cout<< ".";}            } else {cout<< ".";}}        cout<<endl; }} return 0;} 
We're All Jiang.

Solution: string processing (according to test INSTRUCTIONS)

#include <stdio.h>int main () {    int n,t,i;    Char a[1000];    scanf ("%d", &n);    GetChar ();    While (n--)    {        i=0;              Gets (a);        For (t=0;a[t]!= ' + '; t++)        {            if (a[t]== ' 1 ')             printf ("love jiangli\n");            If (a[t]== ' 2 ')            printf ("love xingong\n");        }    }    Return 0;}
Palindrome Prime

Solution: the data is not small, of course, the first judge is not a palindrome and then judge the prime, (here can be a number a decomposition upside down to see if it is Equal)

#include <stdio.h> int main () {     int m,n,c,b,k,p,q,r;     While (scanf ("%d%d", &m,&n)!=eof)     {         if (m==0&&n==0) break             ;         r=0;         For (k=m; k>=m&&k<=n; k++)         {             b=0;             p=k;             While (k>0)             {                 c=k%10;                 b=b*10+c;                 k=k/10;             }             If (b==p)             {for                 (q=2; q<p; q++)                     if (p%q==0) break                         ;                 If (q==p)                 {                     r=r+1;                 }             }             k=p;         }         printf ("%d\n", r);     } }  
Beast and Beast throw shot

Solution: Math problem, Nothing to say

#include <stdio.h> #include <math.h>int main () {    int n;    Float h,a,l;    While (scanf ("%d", &n)!=eof)    {while        (n--)        {            scanf ("%f%f", &h,&a);            L=h/tan (a);            printf ("%.3f\n", l);        }    }    Return 0;}
Warcraft

Solution: it should be calculated slope (y2-y1) * (x3-x1) = = (y3-y1) * (x2-x1)

#include <stdio.h>int main () {    double x1,x2,x3,y1,y2,y3;    int n;    While (scanf ("%d", &n)!=eof)    {for        (int i=0;i<n;i++)        {            scanf ("%lf%lf%lf%lf%lf%lf",& x1,&y1,&x2,&y2,&x3,&y3);            If ((y2-y1) * (x3-x1) = = (y3-y1) * (x2-x1) && (x2-x1) * (x2-x1) >= (x3-x1) * (x3-x1) && (y2-y1) * (y2-y1) >= (y3-y1) * (y3-y1))            printf ("yes\n");            else printf ("no\n");        }    }    Return 0;}

  

2013 C Language Program design competition (junior group), Jiangxi University of Technology

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.