"C Language", "fake question", XUPT Online Judge, classic question type, xupt

Source: Internet
Author: User

"C Language", "fake question", XUPT Online Judge, classic question type, xupt

In the school OJ Network (http://www.xyjudge.com/) Brush some questions, some questions worth finishing on the blog.

The first day of the 3.6 S is just getting started, slowly add those more classic, and try to use a variety of methods to find out which one is the most suitable.

 

1 # include <stdio. h> 2 # include <math. h> 3 # define A 2 4 5 int f (int I, int k) 6 {7 int j; 8 j = k * A * pow (10, I ); 9 return j; 10} 11 12 int main () 13 {14 int n, I, j, k, sum = 0; 15 scanf ("% d", & n ); 16 k = n; 17 for (I = 0; I <n; I ++) 18 {19 j = f (I, k); 20 sum + = j; 21 k --; 22} 23 printf ("% d", sum); 24 return 0; 25}2 + 22 + 222 +... + n 2

 

1 # include <stdio. h> 2 3 int main () 4 {5 int m, n, max, min, I; 6 scanf ("% d", & m, & n ); 7 if (m <n) 8 {9 m = m + n; 10 n = m-n; 11 m = m-n; 12} 13 for (I = n; i> 0; I --) 14 {15 if (m % I = 0 & n % I = 0) 16 {17 max = I; 18 break; 19} 20} 21 for (I = m; I ++) 22 {23 if (I % m = 0 & I % n = 0) 24 {25 min = I; 26 break; 27} 28} 29 printf ("% d", max, min); 30 return 0; 31}Maximum common approx. and minimum public multiple

 

1 # include <stdio. h> 2 3 4 int main () 5 {6 int a, B [5] = {0, 0, 0}, I = 0, len = 0; 7 scanf ("% d", & a); 8 while (I <5) 9 {10 B [I] = a % 10; 11 a = a/10; 12 len ++; 13 if (a = 0) 14 break; 15 I ++; 16} 17 printf ("% d \ n", len ); 18 for (I = len-1; I> 0; I --) 19 printf ("% d", B [I]); 20 printf ("% d \ n ", B [I]); 21 for (I = 0; I <len; I ++) 22 printf ("% d", B [I]); 23 return 0; 24}Determine the number of digits of a number and the number of reverse orders (inverted output)

 

1 # include <stdio. h> 2 # include <math. h> 3 4 int main () 5 {6 int I, j, k, t, sum; 7 for (I = 100; I <= 999; I ++) 8 {9 sum = 0; 10 k = I; 11 for (j = 0; j <3; j ++) 12 {13 t = k % 10; 14 sum + = pow (t, 3); 15 k = k/10; 16} 17 if (I = sum) 18 printf ("% d \ n ", i); 19} 20 return 0; 21}The number of daffodils between 100 and 999 (three vertices in each of the three digits and equal to this digit)

 

1 # include <stdio. h> 2 # include <math. h> 3 4 void ifperfect (int n) 5 {6 int I, k = 0, a [100] = {0}, sum = 0; 7 for (I = 1; I <n; I ++) 8 {9 if (n % I = 0) 10 {11 a [k] = I; 12 sum + = a [k]; 13 k ++; 14} 15} 16 if (n = sum) 17 {18 printf ("% d its factors are", n); 19 for (I = 0; I <sizeof (a)-1; I ++) 20 {21 if (a [I + 1] = 0) 22 break; 23 printf ("% d ", a [I]); 24} 25 printf ("% d \ n", a [I]); 26} 27} 28 29 int main () 30 {31 int n, i, j; 32 scanf ("% d", & n); 33 for (I = 1; I <n; I ++) 34 ifperfect (I ); 35 return 0; 36}Returns the complete number within n (it is equal to the sum of all its factors)

 

1 # include <stdio. h> 2 3 int main () 4 {5 int I, j, a [10]; 6 for (I = 0; I <10; I ++) 7 scanf ("% d", & a [I]); 8 for (I = 0; I <9; I ++) 9 {10 for (j = I + 1; j <10; j ++) 11 {12 if (a [I]> a [j]) 13 {14 a [I] ^ = a [j]; 15 a [j] ^ = a [I]; 16 a [I] ^ = a [j]; 17} 18} 19} 20 for (I = 0; I <10; I ++) 21 {22 printf ("% d \ n", a [I]); 23} 24 return 0; 25}Array sorting

 

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.