C Exercise Example 89
100 cases of classic C language
Title: The adoption of a public telephone to transfer data, the data is an integer of four, and in the transfer process is encrypted, the encryption rules are as follows: Each figures plus 5, then divided by 10, the remainder in place of the numbers, then swap the first and fourth, second and third exchange.
Program Analysis: None.
Source Code:
// Created by www.w3big.com on 15/11/9. // Copyright © 2015年 本教程. All rights reserved. // #include<stdio.h> #include<stdlib.h> int main() { int n,i,j; printf("请输入数字:\n");i--; for(i=0;i<7;i++) { scanf("%d",&n); if(n>50){ printf("请重新输入:\n");i--; } else { for(j=0;j<n;j++) printf("*"); } printf("\n"); } return 0; }
Run the above example output is:
输入一个要加密的四位整数: 1234 加密后的数为9876