[c++ ] Vedic Square and Vedic Star

#include<iostream>

using namespace std;

int main() {

int j;  int i;

int k;

int a[100][100]={0};

for (i = 1; i<10; i++)

a[i][0]=i;

for (j = 1; j<10; j++)

a[0][j]=j ;

for (i = 1; i < 10;i++) {

for (j = 1; j < 10;j++)    {

a[i][j] = a[i][0]*a[0][j];

k= a[i][j];

if (a[i][j]>9)

a[i][j] = k / 10 + k % 10;

if (a[i][j] > 9){

k = a[i][j];

a[i][j] = k / 10 + k % 10;

}

}

}

for (i = 0; i<10; i ++)   {

for (j = 0; j < 10; j++)

if (j ==9)

cout << a[i][j] << endl;

else

cout << a[i][j] ;

}

int h;

cin>>h;

for (i = 1; i<10; i ++)   {

for (j = 1; j < 10; j++)

if (h==a[i][j])

cout << ‘*‘ ;

else

cout <<‘ ‘ ;

cout<<‘\n‘;

}

return 0;

}

时间: 2024-12-31 03:53:20

[c++ ] Vedic Square and Vedic Star的相关文章

python基础2 -画图

? #!/usr/bin/env python # -*- coding: utf-8 -*- # Created by xuehz on 2017/4/9 import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt from scipy.stats import norm, poisson import time from scipy.optimize import leastsq from scipy

绘图:Matplotlib

用于绘制一些数据图,同学推荐的,挺好用.非常好的官网文档:http://matplotlib.org/contents.html 0. 安装 可以直接pip install,还有一些依赖就按照提示来吧,具体也忘了. 1. 基本画图 import matplotlib.pyplot as plt xs = [1,2,3,4] ys = [1,2,3,4] plt.plot(xs, ys) plt.show() xs表示点的x坐标,ys表示点的y坐标,所画的点就是(xs[i], ys[i]),默认情

c语言 弹弹球小游戏

#include <stdio.h>#include <stdlib.h>#include <windows.h>#include <time.h>#include<mmsystem.h>#pragma comment(lib, "WINMM.LIB") #define BRICK_NUM 100//形状类型#define SQUARE 1#define STAR 2#define DIAMOND 3 /*建立对应模型:20/

Python绘制常见图形

!/usr/bin/python -- coding:utf-8 -- import numpy as np import matplotlib as mpl from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm import time from scipy.optimize import leastsq from scipy import stats import scipy.optimize as opt impo

How an Undocumented Immigrant From Mexico Became a Star at Goldman Sachs

How an Undocumented Immigrant From Mexico Became a Star at Goldman Sachs Julissa Arce went from selling funnel cakes in Texas to derivatives at Wall Street’s most profitable securities firm Don't Miss Out — byMax Abelson 7:00 PM AWST February 25, 201

poj-2420 A Star not a Tree?(模拟退火算法)

题目链接: A Star not a Tree? Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5219   Accepted: 2491 Description Luke wants to upgrade his home computer network from 10mbs to 100mbs. His existing network uses 10base2 (coaxial) cables that allo

[leetcode] 367. Valid Perfect Square

Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library function such as sqrt. Example 1: Input: 16 Returns: True Example 2: Input: 14 Returns: False 使用二分查找寻找input

Project Euler 92:Square digit chains C++

A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before. For example, 44 → 32 → 13 → 10 → 1 → 1 85 → 89 → 145 → 42 → 20 → 4 → 16 → 37 → 58 → 89 Therefore any chain that

LeetCode Maximal Square

Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Return 4. 思路分析:这题考察DP.缓存中间结果降低反复计算.DP方程为 if(matrix[i][j